如何使用无头浏览器在 Jenkins 中运行量角器测试用例? [英] How to run protractor testcases in Jenkins with a headless browser?

查看:17
本文介绍了如何使用无头浏览器在 Jenkins 中运行量角器测试用例?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了 phantomjs,但 phantom js 与量角器的兼容性不好.虽然在 chrome 和 firefox 浏览器中我能够找到元素,但在 phantomjs 中找不到相同的定位器.

I have used phantomjs but compatibility of phantom js is bad with protractor. Though in chrome and firefox browser I am able to find elements but same locators are not found in phantomjs.

推荐答案

如果您使用的是 linux 操作系统,那么您可以使用 xvfb 以无头模式启动 chrome 浏览器.

If you are using linux OS then you can use xvfb to launch the chrome browser in headless mode.

要安装 xvfb,请在终端中运行以下命令

To install xvfb, run the below commands in terminal

sudo apt-get update

sudo apt-get install -y xvfb

安装 xfvb 后,您可以使用以下命令运行量角器脚本,

Once you install xfvb, you can run your protractor scripts using the below command,

xvfb-run protractor configuration.js

上述命令将以无头模式启动您的 chrome 浏览器,并将执行 configuration.js 文件中提到的所有规范.

The above command will start your chrome browser in headless mode and will execute all specs mentioned in the configuration.js file.

这篇关于如何使用无头浏览器在 Jenkins 中运行量角器测试用例?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆