Press TAB and then ENTER key in Selenium WebDriver with Ruby

AJJ picture AJJ · Apr 6, 2012 · Viewed 33.4k times · Source

I am doing automated testing using Selenium WebDriver with Ruby. I need to click a button. I cannot get the button element by id or css or xpath as the button is transparent. I would like to use Tab and Enter key to press the button.

I can use Tab key to get the button as below:

@element.send_keys :tab
@element --> any javascript element visible in the browser

But how do I use the Enter key on the button?

Basically I need to achieve press Tab key and then press Enter key to click the button.

I am using Selenium WebDriver @driver = Selenium::WebDriver.for :firefox

Answer

ShockwaveNN picture ShockwaveNN · Apr 12, 2012

In Ruby user1316's code looks like

driver.action.send_keys(elementVisible, :tab).send_keys(elementVisible, :return).perform