gpt4 book ai didi

ruby - 按 T​​AB 键,然后在带有 Ruby 的 Selenium WebDriver 中按 ENTER 键

转载 作者:数据小太阳 更新时间:2023-10-29 06:59:12 30 4
gpt4 key购买 nike

我正在使用 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 - 按 T​​AB 键,然后在带有 Ruby 的 Selenium WebDriver 中按 ENTER 键,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10040953/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com