我无法使用selenium web-driver传递文本框中的数据。 我使用过xpath,id,name但它们都没有工作。
driver.findElement(By.xpath("//input[@id='step2_portno_1']").sendKeys("80");
driver.findElement(By.id("step2_portno_")).sendKeys("80");
> error:unable to locate the x path..
请帮助解决上述问题。
答案 0 :(得分:0)
问题似乎是硒无法定位元素。 一旦获得元素,只有sendkeys才能工作。
尝试以下:
示例:
WebElement div1 = driver.findElement(By.id("myDiv"));
WebElement myElement = div1.findElement(By.id("step2_portno_"));