开发者

How to send KeyStroke in selenium to browser window (without locator)

Can i send KeyStroke in Selenium in Java without using a locator?

I want to send KeyStroke to WebBrowser itself, because I don't know element (and its locator), to whom I must send KeyStroke t开发者_如何转开发o perform action, which I want. But I know, that action performing correctly, when I manually select browser as active window and just press 'Enter' on the keyboard without selecting any element on the page.

I tried this code

SeleniumSession.keyPressNative(Integer.toString(KeyEvent.VK_ENTER));

but it didn't work for me.


What about sending it to the HTML element - ie find element by xpath "/html" and sendKeys() to it?


I'd try "//body", but I'm not sure it will work in the Selenium RC API. This is one of the things that Selenium 2.x's WebDriver API was designed to make work well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜