How to click the XPath that is saved in excel file

Hello everyone,
I have saved some details including the XPath of the toggle button in the excel sheet (I have attached the screenshot below). I want to click the continue button that is on the website and the XPath should be taken from the Excel sheet.

This is what I have so far;

    ## Click the continue button
    sleep  10s
    click element  ${LOCATOR_Continue}    ${Element}
    sleep  10s
    EXECUTE JAVASCRIPT    window.scrollTo(200,400)
    sleep  10s

But this code is not working. It displays an error message as “TC_01 | FAIL | ValueError: ‘xpath://*[@id=“cols”]’ modifier does not match to Selenium Keys”

So, I request you to help me to solve this problem. Thank You

To work with excel, first, you need to have an excel library ie. [ExcellentLibrary]

Give the excel sheet path.
Open it.
Switch to the required sheet.
Pick the row & column statically or can use dynamically using keywords in the library.
Use it as per your need.

Or else you can use the data driver library, but accordingly, to the library, you need to arrange the TC’s.

1 Like

Previously I have sent the part of my code. And also I have already install the Robotframework-DatabaseLibrary.

*** Settings ***

Common Resources

Resource /users/TestAutomation/Variables/variable.robot

Test case dependencies

Library DataDriver file=/users/TestAutomation/FA.xlsx encoding=UTF-8

Test Setup Begin Test
Test Template Fill the form
Test Teardown Close Browser

*** Test Cases ***
Fill the form

*** Keywords ***

Begin Test
Open Browser ${BASE_URL} gc
maximize browser window

Fill the form

 [Arguments]     ${Email_Address}  ${Password}  ${Element}

    input text    ${LOCATOR_Email_Address}    ${Email_Address}
    input text    ${LOCATOR_Password}    ${Password}
    ## Press the login button
    Click element  xpath://html/body/app-root/div/div/app-auth/app-auth-sign-in/mat- 

    Sleep  30s

    ## Click the continue button
    sleep  10s
    click element  ${LOCATOR_Continue}    ${Element}
    sleep  10s
    EXECUTE JAVASCRIPT    window.scrollTo(200,400)
    sleep  10s

    ## Enter the value
    input text  ${LOCATOR_AMOUNT}   5000
    sleep  2s

    ## Click request Button
    click element  xpath=//button[contains(.,'Request')]
    sleep  5s

This is what I have do so far. But, it’s still not working.
Can I click the XPath by using this → " click element ${LOCATOR_Continue} ${Element}" ?

If your question simply relates to the means of using an external data source for your tests:

Use the Robot Framework DataDriver library (>= 1.5.0) in conjunction with the preserve_xls_types option - see Then format your cell in Excel as “text”. This should do the trick. If your code still does not work, then I would verify it by temporarily removing the Excel constraint and getting that value from e.g. a variable.

1 Like