gpt4 book ai didi

Node.JS selenium 发送 key 回车

转载 作者:搜寻专家 更新时间:2023-10-31 22:39:36 25 4
gpt4 key购买 nike

当我在 Node js 中发送返回键时它给出错误?

driver.findElement(By.id('twofactorcode_entry')).sendKeys(Keys.ENTER);

所有网站都告诉我这是我需要使用的?请帮忙

最佳答案

我假设您正在使用 npm 包 Selenium Webdriver:https://www.npmjs.com/package/selenium-webdriver

Keys is not defined 错误是因为你在使用前没有定义keys。您需要使用枚举 key ( https://seleniumhq.github.io/selenium/docs/api/javascript/module/selenium-webdriver/index_exports_Key.html )

它是驱动程序模块上的常量,并作为 Key 导出(注意单数形式)。我已将更新后的代码放在下面。

const driver = require('selenium-webdriver')

driver.findElement(By.id('twofactorcode_entry')).sendKeys('webdriver', driver.Key.ENTER);

额外提示:我一直在使用 http://webdriver.io/而且它比这个库更容易使用

关于Node.JS selenium 发送 key 回车,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41428871/

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