我正在使用 Selenium WebDriver 和 Ruby 进行自动化测试。我需要点击一个按钮。我无法通过 id 或 css 或 xpath 获取按钮元素,因为按钮是透明的。我想使用 Tab 和 Enter 键来按下按钮。
我可以使用 Tab 键来获取按钮,如下所示:
@element.send_keys :tab
@element --> any javascript element visible in the browser
但是如何使用按钮上的 Enter 键呢?
基本上我需要实现按Tab键然后按Enter键点击按钮。
我正在使用 Selenium WebDriver @driver = Selenium::WebDriver.for :firefox
最佳答案
在 Ruby 中 user1316 的代码看起来像
driver.action.send_keys(elementVisible, :tab).send_keys(elementVisible, :return).perform
关于ruby - 按 TAB 键,然后在带有 Ruby 的 Selenium WebDriver 中按 ENTER 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10040953/