在 Tosca 谜题 23292 中,但使用 RobotFrameWork 解决...我在 Xpath 测试器中导致 1 个位置的元素上尝试了 Xpath。但是在实际的 VisualStudioCode 结果中,它给出了一条错误消息:
Example Test 23292
[ FAIL ] Error: page.$: Evaluation failed: Error: strict mode violation: selector resolved to 6 elements.
at u.querySelector (<anonymous>:3:34807)
at eval (eval at evaluate (:3:1339), <anonymous>:6:23)
at t.default.evaluate (<anonymous>:3:1362)
at t.default.<anonymous> (<anonymous>:1:44)
我尝试如下:
*** Settings ***
# https://robotframework-browser.org/
Library Browser
#Library SeleniumLibrary run_on_failure=nothing
#Library SeleniumLibrary
*** Test Cases ***
Example Test 23292
Browser.OPEN BROWSER https://obstaclecourse.tricentis.com/Obstacles/23292
# https://marketsquare.github.io/robotframework-browser/Browser.html#Drag%20And%20Drop
#
DRAG AND DROP xpath=//*[contains(text(),'1')] id=completed-tasks
# DRAG AND DROP xpath=//*[contains(text(),'1')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# DRAG AND DROP xpath=//*[contains(text(),'2')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# DRAG AND DROP xpath=//*[contains(text(),'3')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# DRAG AND DROP xpath=//*[contains(text(),'4')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# DRAG AND DROP xpath=//*[contains(text(),'5')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# DRAG AND DROP xpath=//*[contains(text(),'6')] xpath=/html/body/div[2]/div[1]/div[1]/div[2]/div/div[2]/div[2]/div/table/tbody/tr[2]/td
# sources:
# https://stackoverflow.com/questions/17373941/what-xpath-that-selects-a-element-in-tr-which-has-a-particular-x-in-one-of-i
所以在这个谜题中我有点摸不着头脑,为什么它会找到 6?