[英]Unable to find element with Xpath Selenium in IE
DOM Explorer of the object :对象的 DOM 资源管理器:
<INPUT tabIndex=0 onkeyup=DisableEnableFields(); onblur=autoValidate(this) id=prvd_org_name onkeydown="return HandleMaxLengths(this, 70,event,'','');" maxLength=70 size=120 name=prvd_org_name isRequired="false" ValidationType="ALPHANUMERICSPACEPUNCTUATION">
Please help me with the xpath请帮助我使用 xpath
Tried below xpaths :在 xpaths 下尝试过:
driver.findElement(By.xpath("//input[@name ='prvd_org_name']"))
driver.findElement(By.xpath("//input[@type= text and @name ='prvd_org_name']"))
Please gimme different alternatives as for the above two it gives me unable to find element请给我不同的选择,因为上面两个它让我无法找到元素
To identify the element you can use either of the following Locator Strategies :要识别元素,您可以使用以下任一定位器策略:
cssSelector
: cssSelector
:
WebElement element = driver.findElement(By.cssSelector("input#prvd_org_name[name='prvd_org_name']"));
xpath
: xpath
:
WebElement element = driver.findElement(By.xpath("//input[@id='prvd_org_name' and @name='prvd_org_name']"));
However, as the element is a dynamic element so to identify the element you need to induce WebDriverWait for the elementToBeClickable()
and you can use either of the following Locator Strategies :但是,由于该元素是一个动态元素,因此要识别您需要为elementToBeClickable()
引入WebDriverWait的元素,您可以使用以下任一定位器策略:
cssSelector
: cssSelector
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.cssSelector("input#prvd_org_name[name='prvd_org_name']")));
xpath
: xpath
:
WebElement element = new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.xpath("//input[@id='prvd_org_name' and @name='prvd_org_name']")));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.