无法在Ubuntu命令行中启动WebdriverIO

时间:2018-11-07 04:22:35

标签: linux selenium ubuntu error-handling webdriver-io

我按照以下步骤在Linux计算机( Ubuntu )上安装Webdriver。

  • 创建目录:mkdir webdriverio-test && cd webdriverio-test

  • 下载硒独立服务器: curl -O http://selenium-release.storage.googleapis.com/3.5/selenium-server-standalone-3.5.3.jar

  • 下载gheckodriver

curl -L https://github.com/mozilla/geckodriver/releases/download/v0.16.0/geckodriver-v0.16.0-linux64.tar.gz | tar xz

  • 启动Selenium WebDriver:java -jar -Dwebdriver.gecko.driver=./geckodriver selenium-server-standalone-3.5.3.jar

  • 创建一个test.js脚本:


var webdriverio = require('webdriverio');
var options = {
    desiredCapabilities: {
        browserName: 'firefox'
    }
};

webdriverio
    .remote(options)
    .init()
    .url('http://www.google.com')
    .getTitle().then(function(title) {
        console.log('Title was: ' + title);
    })
    .end()
    .catch(function(err) {
        console.log(err);
    });
  • 最后,当selenium-server-standalone在另一个窗口中运行时,在另一个终端窗口中运行上述脚本。
  

!!!问题: 我运行命令后,脚本正在失败,尽管它正在打开Mozilla浏览器。我在做什么错了?

  • 堆栈跟踪错误:

errors screenshots

1 个答案:

答案 0 :(得分:0)

尝试使用chromedriver:

1.进入测试文件夹:

cd webdriverio-test


2.下载chromedriver:

wget https://chromedriver.storage.googleapis.com/2.35/chromedriver_linux64.zip

unzip chromedriver_linux64.zip


3.启动chromedriver:

./chromedriver -port=4444 -url-base=/wd/hub -verbose


4.打开新的终端窗口并运行测试:

node test.js