【发布时间】:2017-01-10 02:30:04
【问题描述】:
我很难让量角器在 Firefox 中运行测试
以下是一个示例测试用例。它可以在 Chrome 中测试 - 但在 Firefox 和 IE 浏览器中失败。
测试文件
<html>
<head>
<title>automation test</title>
<style>
#tst{
width: 200px;
height: 200px;
border: 1px solid;
}
</style>
</head>
<body>
<div id="tst"></div>
<button id="clickme">Click me</button>
<script>
document.getElementById('clickme').addEventListener('click', function(e){
document.getElementById('tst').style.backgroundColor = 'red';
});
</script>
</body>
</html>
规格文件(indexspecs.js)
describe('sample test', function(){
it('change bgColor to red when click the button', function(){
browser.driver.get("http://localhost/test/index.html");
var btn = browser.driver.findElement(by.id('clickme'));
var clRed = "rgba(255, 0, 0, 1)";
btn.click();
expect(browser.driver.findElement(by.id('tst')).getCssValue('background-color')).toEqual(clRed);
});
});
量角器配置文件
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub',
specs: ['indexspecs.js'],
jasmineNodeOpts: {
showColors: true
},
capabilities: {
// 'browserName': 'internet explorer'
'browserName': 'firefox'
}
};
量角器版本 - 2.0.0
Firefox 版本 - 45
IE 版本 - 11
当设置为 Firefox 时,浏览器会启动 - 但不会获取 url 来运行测试。
【问题讨论】:
-
使用 protractor 的 Firefox 版本出现了一些中断,你看过这里吗:stackoverflow.com/questions/37693106/…?
标签: javascript selenium selenium-webdriver protractor angularjs-e2e