Pressing Ctrl+A in Selenium WebDriver

前端 未结 13 1019
一向
一向 2020-11-27 02:45

I need to press Ctrl+A keys using Selenium WebDriver. Is there any way to do it?

I checked the Selenium libraries and found that Selenium allow

13条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-27 03:39

    To click Ctrl+A, you can do it with Actions

      Actions action = new Actions(); 
      action.keyDown(Keys.CONTROL).sendKeys(String.valueOf('\u0061')).perform();
    

    \u0061 represents the character 'a'

    \u0041 represents the character 'A'

    To press other characters refer the unicode character table - http://unicode.org/charts/PDF/U0000.pdf

提交回复
热议问题