Nightwatch.js在执行.setValue

问题描述

我正在尝试运行Nightwatch.js脚本,该脚本可以让我通过Google高级搜索进行搜索。这是我的脚本:

'Google advanced search'(browser){
    const value = 'apple';
    const searchBar = 'name="as_q';
    
    
    browser
        .url('https://www.google.com/advanced_search')
        .setValue(searchBar,value) 
        .saveScreenshot('tests_output/google.png')
}

尝试运行脚本时,.setValue()出现问题,并且总是出现以下错误:

NoSuchElementError:在上运行.click()命令时发生错误:(Session info:chrome = 85.0.4183.121),(Driver info:chromedriver = 85.0 .4183.87(cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs / branch-heads / 4183 @ {#1689}),platform = Windows NT 10.0.19041 x86_64);无效的选择器:指定了无效或非法的选择器 {“状态”:-1,“状态”:“”,“代码”:“”,“值”:{“消息”:“无效的选择器:指定了无效或非法的选择器”,“错误”:[“ (会话信息:chrome = 85.0.4183.121)“,”(驱动程序信息:chromedriver = 85.0.4183.87(cd6713ebf92fa1cacc0f1a598df280093af0c5d7-refs / branch-heads / 4183 @ {#1689}),platform = Windows NT 10.0.19041 x86_64)“]] },“ errorStatus”:32,“ error”:“所提供的参数是一个无效的选择器(例如XPath / CSS)。–无效的选择器:一个无效或非法的选择器已被...”,“ httpStatusCode”:200} 在processTicksAndRejections(internal / process / task_queues.js:97:5)

基本上,它告诉我我使用的选择器(XPath / CSS)出于某种原因无效。 选择器来自页面中的以下元素:

<input class="jfk-textinput" value="" autofocus="autofocus" id="xX4UFf" name="as_q" type="text">

有没有办法解决这个问题?预先谢谢你。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)