[英]Not able to locate input element using Selenium WebDriver
I am new to Selenium. 我是硒的新手。 In a specific scenario I am not able to catch an input element.
在特定情况下,我无法捕获输入元素。 below is the code:
下面是代码:
<ul class = "form1">
<li class="firstName">
<input placeholdervalue="First name" tabindex="1" placeholder="First name" class="text" placeholdevalue="First name" data-input-rule="name" data-value-rule="required" maxlength="20" type="text">
</li>
</ul>
I want to locate input element. 我想找到输入元素。 I tried locating it using locator
By.ClassName
, By.CssSelector("input[class='text placeholder']")
and also tried: 我尝试使用定位器
By.ClassName
, By.CssSelector("input[class='text placeholder']")
定位它,并尝试:
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("input[className='text' and placeholdevalue='First name'"))).SendKeys("Vipul");
but input element is not getting selected. 但没有选择输入元素。 Please let me know the right way to select input element.
请让我知道选择输入元素的正确方法。
I would use a dot
notation to match the classes of ul
, li
and input
elements: 我将使用
dot
表示法来匹配ul
, li
和input
元素的类:
By.CssSelector("ul.form1 li.firstName input.text")
If the element still cannot be found, then there could two most commonly met reasons: 如果仍然找不到该元素,则可能有两个最常见的原因:
I'll expand these items in case you would still have problems finding the element. 如果您仍然找不到元素,我将扩展这些项目。
Thanks for the reply. 谢谢回复。
It worked with this, 为此,
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(20));
wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("ul.form1 li.firstName input.text"))).SendKeys("Vipul");
Is this the right way of using wait? 这是使用等待的正确方法吗?
Also, can anybody point out to resources which explain working with frames using selenium webdriver? 另外,有人可以指出使用Selenium Webdriver解释使用框架的资源吗?
-Amit -阿米特
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.