所以我尝试使用 selenium 单击下一步按钮,我尝试使用下面的代码,但它以错误结束.
So Im trying to I click the next button using selenium, I've tried with the code below, but it ends in error.
元素
<input type="submit" name="submitNext" value="Next">
我的代码
driver.find_element_by_name("submitNext").click()
然后它会输出这些错误
Traceback (most recent call last):
File "C:/Users/thomas/PycharmProjects/test/mainapp/main.py", line 194, in
<module>
visa()
File "C:/Users/thomas/PycharmProjects/test/mainapp/main.py", line 174, in visa
driver.find_element_by_name("submitNext").click()
File "C:Users homasPycharmProjectsBudgetMainvenvlibsite-packagesseleniumwebdriver
emotewebdriver.py", line 487, in find_element_by_name
return self.find_element(by=By.NAME, value=name)
File "C:Users homasPycharmProjectsBudgetMainvenvlibsite-packagesseleniumwebdriver
emotewebdriver.py", line 955, in find_element
'value': value})['value']
File "C:Users homasPycharmProjectsBudgetMainvenvlibsite-packagesseleniumwebdriver
emotewebdriver.py", line 312, in execute
self.error_handler.check_response(response)
File "C:Users homasPycharmProjectsBudgetMainvenvlibsite-packagesseleniumwebdriver
emoteerrorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"name","selector":"submitNext"}
(Session info: chrome=66.0.3359.170)
(Driver info: chromedriver=2.36.540470 (e522d04694c7ebea4ba8821272dbef4f9b818c91),platform=Windows NT 10.0.16299 x86_64)
任何人对如何正确单击该按钮有任何想法?
Anyone have any ideas as to how to click that button without errors?
这个错误信息...
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"name","selector":"submitNext"}
(Session info: chrome=66.0.3359.170)
(Driver info: chromedriver=2.36.540470)
...暗示 ChromeDriver 无法找到所需的元素.
...implies that the ChromeDriver was unable to locate the desired element.
根据您共享的 HTML 来单击元素,您可以使用以下任一定位器策略:
As per the HTML you have shared to click on the element you can use either of the following Locator Strategies :
css_selector:
driver.find_element_by_css_selector("input[name='submitNext'][value='Next']").click()
xpath:
driver.find_element_by_xpath("//input[@name='submitNext' and @value='Next']").click()
但是您的主要问题是您使用的二进制文件之间的版本兼容性,如下所示:
However your main issue is the version compatibility between the binaries you are using as follows :
支持 Chrome v63-65
支持 Chrome v65-67
所以 ChromeDriver v2.36 和 Chrome 浏览器 v66.0 之间存在明显的不匹配
So there is a clear mismatch between the ChromeDriver v2.36 and the Chrome Browser v66.0
@Test.@Test.这篇关于selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:尝试使用 selenium 单击下一步按钮时无法找到元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
如何在python中的感兴趣区域周围绘制一个矩形How to draw a rectangle around a region of interest in python(如何在python中的感兴趣区域周围绘制一个矩形)
如何使用 OpenCV 检测和跟踪人员?How can I detect and track people using OpenCV?(如何使用 OpenCV 检测和跟踪人员?)
如何在图像的多个矩形边界框中应用阈值?How to apply threshold within multiple rectangular bounding boxes in an image?(如何在图像的多个矩形边界框中应用阈值?)
如何下载 Coco Dataset 的特定部分?How can I download a specific part of Coco Dataset?(如何下载 Coco Dataset 的特定部分?)
根据文本方向检测图像方向角度Detect image orientation angle based on text direction(根据文本方向检测图像方向角度)
使用 Opencv 检测图像中矩形的中心和角度Detect centre and angle of rectangles in an image using Opencv(使用 Opencv 检测图像中矩形的中心和角度)