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
In Ruby user1316's code looks like
driver.action.send_keys(elementVisible, :tab).send_keys(elementVisible, :return).perform
Keeping in mind the excerpt :
I can use tab key to get the button as
@element.send_keys :tab
@element --> any javascript element visible in the browser
but how do i use the enter key on the button??
In order to use the enter key on the button, you could try one of the solution provided using Ruby here. This basically talks about sending the :return
value and not the :enter
value i.e @element.send_keys :return
and some additional information.
UPDATED:
I could provide some code in Java which tries to implement the problem conceptually using the info provided here. You could try to translate for the corresponding Ruby Selenium API.
The Code:
Actions builder = new Actions(driver);
builder.sendKeys( elementVisible, Keys.TAB).sendKeys(Keys.RETURN);
Action submitTheTransperentButton = builder.build();
submitTheTransperentButton.perform();
use Selenium::WebDriver::Keys::KEYS[:tab]
ref: https://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/Keys
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With