gpt4 book ai didi

node.js - 使用 Selenium 和 Node 进行 Chromedriver 模拟

转载 作者:太空宇宙 更新时间:2023-11-03 22:00:25 32 4
gpt4 key购买 nike

尝试使用 chromedriver 模拟移动设备来设置 e2e 测试。我们在 Mac OS 上使用 chromedriver 2.3,但提供的 chromeOptions 似乎无效:

var webdriver = require('selenium-webdriver');
var capabilities = {
browserName: 'chrome',
chromeOptions: {
mobileEmulation: {
deviceName: 'Apple iPhone 5'
}
}
};

var driver = new webdriver
.Builder()
.withCapabilities(capabilities)
.build();

driver.get('http://google.com');

var bool = false;
setTimeout(function () {
bool = true;
}, 9000);
driver.wait(function() {
return bool;
}, 10000);

driver.quit();

我做错了什么?这是错误的堆栈跟踪:

UnknownError: unknown error: cannot parse capability: chromeOptions
from unknown error: unrecognized chrome option: mobileEmulation
(Driver info: chromedriver=2.3,platform=Mac OS X 10.10.1 x86_64)
at new bot.Error (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/atoms/error.js:113:18)
at Object.bot.response.checkResponse (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/atoms/response.js:106:9)
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/webdriver.js:152:24
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/goog/base.js:1582:15
at webdriver.promise.ControlFlow.runInNewFrame_ (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:1654:20)
at notify (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:465:12)
at notifyAll (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:442:7)
at resolve (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:420:7)
at fulfill (/Users/michael/cdTest/node_modules/selenium-webdriver/lib/webdriver/promise.js:535:5)
at /Users/michael/cdTest/node_modules/selenium-webdriver/lib/goog/base.js:1582:15

最佳答案

我在使用 Chrome 驱动程序 2.9 时遇到了同样的问题,自从我将其替换为 the newest Chrome Driver 2.15 后,它现在工作正常。 .

关于node.js - 使用 Selenium 和 Node 进行 Chromedriver 模拟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27533447/

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