在Visual Studio中输入以下代码,然后在终端输出中键入“ node index.js”,这将给我:
“ WebDriverError:未知错误:'url'必须为字符串”
-尝试仅使用driver.get(URL);并输入到终端输出“ Set URL = {http://port-80-6p76k7hj7t.treehouse-app.com/节点index.js”中,该错误将返回错误消息“找不到与参数'index.js'相匹配的位置参数”
-尝试使用\和//作为URL
这是我正在使用的代码:
require('chromedriver');
const selenium = require('selenium-webdriver');
const By = selenium.By;
const driver = new selenium.Builder().forBrowser("chrome").build();
driver.get("https://port-80-6p76k7hj7t.treehouse-app.com/");
const locators = { inviteeForm: By.id("registrar"), inviteeNameField: By.name("name") };
function addInvitee(name) { driver.findElement(locators.inviteeNameField).sendKeys(name); driver.findElement(locators.inviteeForm).sub(); }
add invitee("Kevin Smith");
add invitee("Joe Smith");
我遇到的错误是:
[ERROR] node : C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\promise.js:2626
[ERROR] At line:1 char:1
[ERROR] + node index.js
[ERROR] + ~~~~~~~~~~~~~
[ERROR] + CategoryInfo : NotSpecified: (C:\users\kevin....promise.js:2626:String) [], RemoteException
[ERROR] + FullyQualifiedErrorId : NativeCommandError
[ERROR]
[ERROR] throw error;
[ERROR] ^
[ERROR]
[ERROR] WebDriverError: unknown error: 'url' must be a string
[ERROR] (Session info: chrome=68.0.3440.106)
[ERROR] (Driver info: chromedriver=2.28.455520 (cc17746adff54984afff480136733114c6b3704b),platform=Windows NT 10.0.17134 x86_64)
[ERROR] at Object.checkLegacyResponse (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\error.js:546:15)
[ERROR] at parseHttpResponse (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\http.js:509:13)
[ERROR] at doSend.then.response (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\http.js:441:30)
[ERROR] at process._tickCallback (internal/process/next_tick.js:68:7)
[ERROR] From: Task: WebDriver.navigate().to(undefined)
[ERROR] at thenableWebDriverProxy.schedule (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\webdriver.js:807:17)
[ERROR] at Navigation.to (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\webdriver.js:1133:25)
[ERROR] at thenableWebDriverProxy.get (C:\users\kevin.yu\selenium-basics\node_modules\selenium-webdriver\lib\webdriver.js:988:28)
[ERROR] at Object.<anonymous> (C:\users\kevin.yu\selenium-basics\node_modules\index.js:12:8)
[ERROR] at Module._compile (internal/modules/cjs/loader.js:689:30)
[ERROR] at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
[ERROR] at Module.load (internal/modules/cjs/loader.js:599:32)
[ERROR] at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
[ERROR] at Function.Module._load (internal/modules/cjs/loader.js:530:3)
[ERROR] at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
[ERROR]
我被永久卡住,请发送帮助! 预先感谢!