[英]How to find this element in Selenium
The HTML is: HTML是:
<div style="float: left; margin-left: 0px;">
<input class="v-textfield v-textfield-InputTextFieldStyle
InputTextFieldStyle v-textfield-focus" type="text" style="width: 56em;"
maxlength="160"/>
</div>
The XPath of the required text field is coming as:所需文本字段的 XPath 如下:
.//*[@id='inputLayout']/div/div[1]/div[2]/input
Absolute XPath:绝对 XPath:
html/body/div[1]/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div[1]/div[2]/input
However Selenium gives NoSuchElementException
.然而,Selenium 给出了
NoSuchElementException
。 How to find this text field element in Selenium?如何在 Selenium 中找到这个文本字段元素?
Use the following CSS selector:使用以下 CSS 选择器:
wait.until(ExpectedConditions.visibilityOfElementLocated(By.cssSelector(".v-textfield.v-textfield-InputTextFieldStyle.InputTextFieldStyle.v-textfield-focus")));
Hope it helps you!希望对你有帮助!
p=driver.find_element_by_xpath("html/body/div[1]/div/div[2]/div/div[2]/div/div/div/div[1]/div/div/div/div[1]/div[2]/input")
p.text
Try the above code and let me know if you need any help试试上面的代码,如果您需要任何帮助,请告诉我
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.