1

In Tosca puzzle 23292, but solving with RobotFrameWork... I tried a Xpath on an element which in Xpath tester results in 1 location. however in the actual VisualStudioCode result it gives an error message:

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)

what I tried is as follow:

    *** 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

So in this puzzle I'm a bit in the dark, why does it find 6?

LTL
  • 339
  • 1
  • 9
  • "why does it find 6" because there are 6 elements that have the character "1" in their text() value. Fix the locator to be more specific, and target one element only. – Todor Minakov Sep 29 '21 at 08:46

0 Answers0