Selenium Webdriver Python,无法按值查找? [英] Selenium webdriver python, cannot find by value?
本文介绍了Selenium Webdriver Python,无法按值查找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试选择页面上的三个复选框之一,但是它们的源代码如下:
I'm trying to select one of three checkboxes on a page but the source code for them looks like this:
<input type="radio" name="Option" value="1">
<input type="radio" name="Option" value="2">
<input type="radio" name="Option" value="3">
因此区别它们的唯一是值,但是没有find_element_by_value.我将如何在这三个复选框之间切换?
So the only thing differentiating them is value, but there is no find_element_by_value. How would I go about switching between these 3 checkboxes?
推荐答案
在这种情况下,您可以使用xpath标识元素,
You can use xpath for identification of elements in such cases,
browser.find_element_by_xpath("//input[@value='1']")
要更好地了解xpaths的工作原理,可以参考以下链接 http://www.toolsqa.com/selenium-webdriver/choosing-effective- xpath/
For a better understanding of how xpaths work, you can refer the below link http://www.toolsqa.com/selenium-webdriver/choosing-effective-xpath/
这篇关于Selenium Webdriver Python,无法按值查找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文