對於量角器我很陌生,想知道爲什麼我的按鈕在使用selenium webdriver管理器在量角器中運行測試時沒有被點擊。量角器css選擇器無法識別的元素
按鈕:
<button class="preview-toggle" icon="add" icon-only="" right="" ng-reflect-router-link="add"></button>
在鑲邊時,我使用下面的選擇:[納克 - 反射 - 路由器鏈路=「添加」]所需的元素被發現。
我量角器,conf.js:
exports.config = {
seleniumAddress: 'http://localhost:4444/wd/hub', // This is targetting my local running instance of the selenium webdriver
specs: [
'./features/**/*.feature'
],
capabilities: {
browserName: 'chrome'
},
framework: 'custom', //We need this line to use the cucumber framework
frameworkPath: require.resolve('protractor-cucumber-framework'), // actual framework
cucumberOpts: {
format: 'pretty',
require: './features/step_definitions/**/*.js' // This is where we'll be writing our actual tests
},
useAllAngular2AppRoots: true
};
我的要素類是一個簡單的
Feature: Cool_feature
Scenario: I do something awesome
Given I open up the application
When I click on add
Then I should be the best
我test.js類
test = function() {
this.Given(/^I open up the application$/, function (callback) {
browser.get('foo.com').then(callback);
});
this.When(/^I click on add$/, function (callback) {
// Write code here that turns the phrase above into concrete actions
browser.element(by.css('[ng-reflect-router-link="add"]')).click().then(callback);
});
this.Then(/^I should be the best"$/, function (callback) {
});
};
module.exports=test;
你不必給'browser.element'。它應該是'element(by.css('[ng-reflect-router-link =「add」]'))' –