- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在编写一个使用 Selenium 的代码。为了测试 find_element_by_css_selector
函数,我编写了以下代码:
self.browserProfile = webdriver.ChromeOptions()
self.browserProfile.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
self.browser = webdriver.Chrome('Chrome_Driver/chromedriver', chrome_options=self.browserProfile)
self.email = email
self.password = password
self.browser.get('http://samplePage.html')
inputs = self.browser.find_element_by_css_selector('button')
print(inputs)
但我收到以下错误:
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"button"}
(Session info: chrome=70.0.3538.77)
(Driver info: chromedriver=2.25.426924 (649f9b868f6783ec9de71c123212b908bf3b232e),platform=Linux 4.15.0-45-generic x86_64)
如何解决这个错误?chromedriver
和所有必需的依赖项均已满足我正在运行 python 3.6。
最佳答案
此错误消息...
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"button"}
...暗示 ChromeDriver 无法通过 Locator Strategy 找到所需的 WebElement您已经使用过。
相关的 HTML 可以帮助我们更好地分析您的问题。但是,您的主要问题是您使用的二进制文件版本之间不兼容,如下所示:
Supports Chrome v53-55
Supports Chrome v70-72
因此,ChromeDriver v2.25 和 Chrome 浏览器 v70.0 之间存在明显的不匹配
@Test
。tearDown(){}
方法中调用 driver.quit()
来关闭和销毁 WebDriver 和 Web Client 优雅地实例化。关于python - Selenium +Python : CSS Selector -- NoSuchElement error,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54968544/
我创建了一个读取这样的文件集的方法(//...是注释,忽略它们): 5 // n jobs 2 // n tools 1 4 5 6 2 1 5 4 2 3 矩阵代表每项工作使用的工具,但在这里并不重
我正在编写读取用户输入的代码,因此我编写了一个程序来执行此操作,读取并返回字符串。当从另一个过程调用它两次时,返回一个 NoSuchElementException 错误,我不知道为什么。 输入阅读器
I have declared two strings and reading the input using Scanner(System.in). 在此之后,当我关闭扫描仪并再次使用扫描仪读取另一
有人可以帮忙解释一下为什么会抛出 NoSuchElement 异常吗?它似乎发生在最后一行 scan.nextInt(); 我正在尝试从文件中读入名称并将它们排序到数组中,然后在打印后从用户那里读入一
对于一个类,我必须创建一个程序,该程序有一个菜单,用户可以根据自己的选择从菜单中选择运行某些方法。我遇到的问题是在我调用我的方法之后,程序在第 30 行抛出 NoSuchElement 异常(当我将代
我们正在一个大项目中使用 GWT。在某些情况下,此代码可以生成 NoSuchElementException : for (Object o: myList) { } 内部没有对ArrayList进行
我已经分享了下面的代码,请让我知道更正 import org.openqa.selenium.By; import org.openqa.selenium.ie.InternetExplorerDri
我有一个 JSP 页面,用户可以在其中选择多个复选框(最多 10 个)。有时,如果选中多个复选框,则会引发 NoSuchElement 异常。 Servlet 代码: Iterator iterat
这个问题已经被一遍又一遍地问了——尽管尝试了所有的技巧,但我似乎仍然无法弄清楚问题出在哪里。 我尝试将 implicitly_wait 增加到 30(甚至增加到 100)- 但它没有用。 用例 -:我
这个问题已经有答案了: Selenium "selenium.common.exceptions.NoSuchElementException" when using Chrome (1 个回答) 已
我正在尝试自动化网络数据表测试。我在用于定位的每个 WebElement 对象中都收到此 NullPointerException。我的代码尽可能简单: public class tableTestS
我有这个方法,应该从 txt 文件中读取,然后在交互 Pane 中打印出读取的信息。该方法有效,我获得了文件中的所有数据,但最终我还打印出了 java.util.NoSuchElementExcept
我试图在程序中使用 Scanner 再次从控制台获取输入,但是当在另一种方法中调用第二个 Scanner 时,它会出现 NoSuchElement异常(exception)。 如果我从运行 fileR
出于某种原因,在 Selenium WebDriver 中单击链接对我来说似乎不起作用,而在 Selenium IDE 中却工作得很好。 我在 Selenium IDE 上构建到 Selenium W
我有以下代码用于从给定列表中选择一个选项,它通常有效,但有时它会失败并在第二个 if 上出现 NoSuchElement 异常。我的印象是,如果它找不到元素,它就会再次返回循环。我相信解释很简单...
我目前有以下代码 while (!visibleTiles.isEmpty())) { tile = visibleTiles.keySet().iterator().next();
我正在编写一个使用 Selenium 的代码。为了测试 find_element_by_css_selector 函数,我编写了以下代码: self.browserProfile = webdrive
我的 Java 1.7 程序执行各种数学函数。我已将函数分成方法,它们可以单独工作。我还制作了一个提示方法,询问用户是否要继续。但是,在输入数字后,我不断收到 NoSuchElement 异常。打印“
当我访问类来测试方法时,每次尝试定义新对象并使用新定义的对象时都会遇到异常。 测试错误: UserInformationControllerTest.deleteUser:83 » NullPoi
我必须创建一个程序,对用户进行 10 个多项选择题的测验,这些问题必须从 .txt 文件读入主类。 到目前为止,为了做到这一点,我已使用 while 循环(在 hasNextLine 条件下)将 .t
我是一名优秀的程序员,十分优秀!