没有这样的元素:无法找到元素:{“方法":“css选择器",“选择器":“body select[name='Accept']"}

2022-01-14 00:00:00 automated-tests php

我有这个

<li><a class="dropdown-item" href="{{route('user.invite_accept',[$user->id,1])}}">Accept</a></li>

我正在尝试使用 laravel 黄昏单击它,我使用了选择、单击、单击链接但它不起作用

I am trying to click on it using laravel dusk I used select, click,clicklink But it doesn't work

推荐答案

您的选择器似乎有误,您似乎正在尝试单击 hyperlink 由 表示<a> 标记,而您的 CSS 表达式正在寻找 <代码><选择>

Your selector seems to be wrong, it appears that you're trying to click a hyperlink which is represented by <a> tag while your CSS expression is looking for a <select>

尝试将您的定位器转换为 通过链接文本查找元素 比如:

Try converting your locator to find element by link text like:

driver.findElement(By.linkText("Accept"))

或者使用 XPath 定位器,例如:

driver.findElement(By.xpath("//a[text()='Accept']"))

相关文章