我一直在用Nightwatch设置一些测试。我在他们的网站上运行了以下基本测试。
module.exports = {
'Search on google': (browser) => {
browser
.url('http://www.google.com')
.waitForElementVisible('body', 1000)
.setValue('input[type=text]', 'nightwatch')
.waitForElementVisible('button[name=btnG]', 1000)
.click('button[name=btnG]')
.pause(1000)
.assert.containsText('#main', 'Night Watch')
.end()
},
after: (browser) => {
browser.end()
}
};
并收到以下错误:
Timed out while waiting for element <button[name=btnG]> to be visible for 1000 milliseconds. - expected "visible" but got: "not visible"
我的第一次纠正尝试是将.waitForElementVisible('button[name=btnG]', 1000)
更改为10000但仍然最终获得Timed out while waiting for element <button[name=btnG]> to be visible for 10000 milliseconds. - expected "visible" but got: "not visible"
。
检查谷歌搜索按钮向我显示按钮名称实际上是btnK所以我测试了但是它没有工作要么返回expected "visible" but got: "not found"
。
非常难过,不知道从哪里开始。有人有想法吗?
答案 0 :(得分:0)
您是否有机会在Chrome 65上运行此功能?最近的更改实际上导致setValue
错误输出。您的Nightwatch测试将在下一步失败。最佳解决方案是将Chromedriver更新为2.36。
答案 1 :(得分:0)
我面临着同样的问题。我已经从NPM安装了v2.45。的ChromeDriver。我的Chrome版本是v69 。当我从此链接https://chromedriver.storage.googleapis.com/index.html?path=2.36/下载chrome驱动程序并更新了nightwatch.json时,它使用export class ReactSample extends React.Component {
constructor(props){
super(props);
this.state = {
items: [],
mappedItems: [],
selectedIds: [],
isSelected: false,
clickedTripId: null
};
this.toggleSelection = this.toggleSelection.bind(this);
}
componentWillMount(){
console.log("Component mounting")
}
toggleSelection (id, e) {
if(!_.includes(this.state.selectedIds, id)) {
this.setState((state) => ({selectedIds:
state.selectedIds.concat(id)}));
this.setState(() => ({clickedTripId: id}));
this.mapItems(this.state.items);
}
}
componentDidMount() {
const self = this;
MyService.getItems()
.then(res => {
self.setState(() => ({ items: res.allItems }));
self.setState(() => ({ mappedItems:
this.mapItems(res.allItems) }));
}
)
}
mapItems (items) {
return items.map(trip => {
return (
<li key={trip.id} onClick={(e) => (this.toggleSelection(trip.id,
e))}>
<span>{trip.title}</span>
<Tick ticked={this.state.clickedTripId}/>
<span className="close-item"></span>
</li>
);
});
}
getItems() {
}
render() {
return (
<div>
<a className="title">This is a react component!</a>
<Spinner showSpinner={this.state.items.length <= 0}/>
<div className="items-container">
<ul id="itemsList">
{this.state.mappedItems}
</ul>
</div>
</div>
);
}
}
export class Tick extends React.Component {
constructor(props) {
super(props);
}
render() {
console.log('RENDER');
return (<span className={this.props.ticked ? 'tick display' :
'tick hide' }></span>);
}
}
指向了此下载的chrome驱动程序版本。这解决了问题。