Karate 需要在空手道UI中使用xpath的帮助吗
我在运行KarateUi测试时遇到了使用xpath的问题Karate 需要在空手道UI中使用xpath的帮助吗,karate,Karate,我在运行KarateUi测试时遇到了使用xpath的问题 Feature: testRun Scenario: google search Given driver 'http://google.com' Then waitForUrl('https://google.com') When if(locate("//input[@name='q']").exists) input("//input[name='q']&quo
Feature: testRun
Scenario: google search
Given driver 'http://google.com'
Then waitForUrl('https://google.com')
When if(locate("//input[@name='q']").exists)
input("//input[name='q']",'testing')
And click('input[name=btnK]')
Then waitFor('{h3}Software testing - Wikipedia')
我得到下面的错误
javascript evaluation failed: if(locate("//input[@name='q']").exists) input("//input[name='q']",'testing'), failed to get reply for: [id: 8, method: Runtime.evaluate, params: {expression=var e = document.evaluate("//input[name='q']", document, null, 9, null).singleNodeValue; e.focus(); try { e.selectionStart = e.selectionEnd = e.value.length } catch(x) {}, returnByValue=true}]
如果有人能帮我解决上面的问题,我将不胜感激
谢谢
Vivek请使用正确的css定位器:
Given driver 'http://google.com'
And input("input[name='q']", 'testing')
And click('input[name=btnK]')
Then waitFor('{h3}Software testing - Wikipedia')
另外,请阅读以下内容:感谢Peter的快速响应,只是想知道xpath为什么不工作,我实际上需要验证左侧导航中的所有元素,这些元素是使用ContainesText找到的特定元素的兄弟元素。提前感谢您的支持这对我也有效:
input(//input[@name='q'])”“测试”)