我有一个搜索框(<input>
元素),我尝试通过写入其中的文本来获取元素。
我尝试做下一个:
// input [@value= "my text"]
Run Code Online (Sandbox Code Playgroud)
但它不起作用(只是要清楚 - 该值不是输入元素的属性。accully,当我检查元素时,我看不到在此文本框中写入的文本)。
<div class="EwdOOOOO">
<div class="GOOOEOOO">Hello </div>
<input type="text" class="GOBLEOOO">
</div>
Run Code Online (Sandbox Code Playgroud)
和我放的座椅盒:
"How are you?"
Run Code Online (Sandbox Code Playgroud)
您可以看到"How are you?"
在 DOM 中没有找到。
谢谢。
我的班级使用Selenium WebDriver并抛出错误.
public class Test_Chromedriver {
public static WebDriver driver;
public static void main(String[] args) {
try {
System.setProperty("webdriver.chrome.driver","E:\\jars\\chromedriver.exe");
WebDriver driver=new ChromeDriver();
driver.get("http://www.facebook.com");
driver.findElement(By.id("email")).sendKeys("surya");
driver.findElement(By.name("pass")).sendKeys("hello");
} catch (Exception e) {
e.printStackTrace();
}
finally{
driver.close();
driver.quit();
}
}
}
Run Code Online (Sandbox Code Playgroud)
一旦我运行上面的代码错误消息得到:
Started ChromeDriver
port=12877
version=23.0.1240.0
log=D:\Eclipse Juno Workspace\AS Selenium workspace\WebDriver Applications\chromedriver.log
Exception in thread "main" java.lang.NullPointerException
at Test_Chromedriver.main(Test_Chromedriver.java:25)
Run Code Online (Sandbox Code Playgroud)
注意:webdriver打开chrome浏览器然后将值输入到字段中,但是上面的错误在控制台中一直显示,最后阻止也没有执行.
我目前正在测试应用程序的GUI,我想知道是否可以将焦点设置为WebElement?
我正在使用Selenium 2.0和webdriver。
所以我正在寻找这样的东西: driver.findElement(xxxx).setfocus();
谢谢。
编辑:我已经疯狂测试了那种棘手的事情
// getting the element WebElement
eSupplierSuggest = driver.findElement(By.xpath("..."));
//get le location and click
Point location = eSupplierSuggest.getLocation();
new Actions(driver).moveToElement(eSupplierSuggest, location.x, location.y).click();
//or
//directly perform
new Actions(driver).moveToElement(eSupplierSuggest).click().perform();
Run Code Online (Sandbox Code Playgroud)
我在某个地方使点击集中了该元素,但在我的情况下,没有任何效果。大声笑
PS:这是该原始帖子的子问题。单击建议框,webdriver