【发布时间】:2021-06-10 20:58:20
【问题描述】:
问题
这段代码应该在 chrome 中打开移动仿真,但由于某种原因它不起作用我正在使用 Selenium 和 express。 Chrome 会打开,但不是在模拟模式下,并且没有出现错误
const express = require('express')
var webdriver = require('selenium-webdriver');
const app = express()
const port = 5000
var capabilities = {
browserName: 'chrome',
chromeOptions: {
mobileEmulation: {
deviceName: 'Apple iPhone 6'
}
}
};
async function google() {
var driver = await new webdriver
.Builder()
.withCapabilities(capabilities)
.build();
await driver.get('https://www.whatismybrowser.com/detect/what-is-my-user-agent')
}
app.get('/', (req, res) => {
google()
})
app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`)
})
【问题讨论】:
标签: javascript node.js selenium google-chrome selenium-webdriver