简体   繁体   English

Selenium Webdriver中的Actions类

[英]Actions Class in Selenium Webdriver

I am trying to perform the Control+A operation using the Actions class in Selenium using the following query:- 我正在尝试使用Selenium中的Actions类通过以下查询执行Control + A操作:

driver.get(" https://jqueryui.com/datepicker/ "); driver.get(“ https://jqueryui.com/datepicker/ ”);

new Actions(driver).keyDown(Keys.CONTROL).sendKeys("a").keyUp(Keys.CONTROL) .build().perform(); 新的Actions(driver).keyDown(Keys.CONTROL).sendKeys(“ a”)。keyUp(Keys.CONTROL).build()。perform();

However , instead doing Control+A for the contents on the Webpage , it is performing the same operation in the URL bar. 但是,不是对网页上的内容执行Control + A,而是在URL栏中执行相同的操作。 Could someone please let me know what is the error here.Moreover the issue what i see is the control stays in the URL bar and it doesnt come down to the Webpage. 有人可以让我知道这里是什么错误。此外,我看到的问题是控件停留在URL栏中,并且没有出现在网页上。

I think there is an issue with pressing keys in selenium 3.0 which is reported here Actions sendKeys UnsupportedCommandException with geckodriver 我认为selenium 3.0中的按键存在问题,在此处报告操作带有geckodriver的sendKeys UnsupportedCommandException

You can try following alternative way to do that - 您可以尝试以下替代方法来做到这一点-

driver.findElement(By.xpath("//body")).sendKeys(Keys.chord(Keys.CONTROL, "a"))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM