量角器测试在重新启动后拾取边缘浏览器而不是chrome

时间:2017-06-07 03:03:22

标签: node.js selenium-webdriver

我试图让服务器安装无头镀铬,硒webdriver和量角器,以便自动化测试。

我使用这些说明设置了我的环境:

# JDK 8
sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update && sudo apt-get install openjdk-8-jdk

# Node JS
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
sudo apt-get install -y nodejs

# NPM modules
sudo npm install protractor -g
sudo npm install chromedriver -g

# Google Chrome
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" | sudo tee -a /etc/apt/sources.list
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install libxpm4 libxrender1 libgtk2.0-0 libnss3 libgconf-2-4
sudo apt-get -y install google-chrome-stable
sudo apt-get -y install xvfb gtk2-engines-pixbuf
sudo apt-get -y install xfonts-cyrillic xfonts-100dpi xfonts-75dpi xfonts-base xfonts-scalable
sudo apt-get -y install imagemagick x11-apps
Xvfb -ac :99 -screen 0 1280x1024x16 &
disown $1
export DISPLAY=:99

问题在于,当我第一次运行量角器测试时,它运行良好且测试运行完美。但是当有服务器重启或其他什么时,我似乎无法再次运行它。现在这是因为当我做webdriver-manager start时,这是我的输出:

yeshwanthvshenoy@node-3:~$ sudo webdriver-manager start
[02:59:54] I/start - java -Djava.security.egd=file:///dev/./urandom -Dwebdriver.chrome.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.29 -Dwebdriver.gecko.driver=/usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.16.1 -jar /usr/lib/node_modules/protractor/node_modules/webdriver-manager/selenium/selenium-server-standalone-3.4.0.jar -port 4444
[02:59:54] I/start - seleniumProcess.pid: 2239
02:59:54.729 INFO - Selenium build info: version: '3.4.0', revision: 'unknown'
02:59:54.730 INFO - Launching a standalone Selenium Server
2017-06-07 02:59:54.758:INFO::main: Logging initialized @329ms to org.seleniumhq.jetty9.util.log.StdErrLog
02:59:54.832 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
 registration capabilities Capabilities [{ensureCleanSession=true, browserName=internet explorer, version=, platform=WINDOWS}] does not match the current platform LINUX
02:59:54.833 INFO - Driver provider org.openqa.selenium.edge.EdgeDriver registration is skipped:
 registration capabilities Capabilities [{browserName=MicrosoftEdge, version=, platform=WINDOWS}] does not match the current platform LINUX
02:59:54.833 INFO - Driver class not found: com.opera.core.systems.OperaDriver
02:59:54.833 INFO - Driver provider com.opera.core.systems.OperaDriver registration is skipped:
Unable to create new instances on this machine.
02:59:54.837 INFO - Driver class not found: com.opera.core.systems.OperaDriver
02:59:54.837 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
02:59:54.842 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
 registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform LINUX
2017-06-07 02:59:54.892:INFO:osjs.Server:main: jetty-9.4.3.v20170317
2017-06-07 02:59:54.942:INFO:osjsh.ContextHandler:main: Started o.s.j.s.ServletContextHandler@523884b2{/,null,AVAILABLE}
2017-06-07 02:59:54.968:INFO:osjs.AbstractConnector:main: Started ServerConnector@2d653761{HTTP/1.1,[http/1.1]}{0.0.0.0:4444}
2017-06-07 02:59:54.969:INFO:osjs.Server:main: Started @541ms
02:59:54.969 INFO - Selenium Server is up and running

如您所见,它显示的是边缘浏览器而不是chrome。为什么它会被切换回来?有没有办法永久存储它,还是我应该做一些其他命令来指定我需要使用chrome?

1 个答案:

答案 0 :(得分:3)

我看到IE,Edge,Safari和Opera被跳过(这是预料之中的)。启动WebDriver管理器后,转到http://localhost:4444/grid/console并检查已注册的内容。

查看量角器的Setting Up the Browser