将重点放在WebElement上?

e1c*_*che 0 java selenium selenium-webdriver

我目前正在测试应用程序的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

小智 5

我通常向该元素发送一个空键,以便它变得集中。因此,例如:

element.send_keys ""
Run Code Online (Sandbox Code Playgroud)