Thank you so much in advance for answering my question. Below I tried to print all the links name in the console. I could able to get no of count of links but could not able to print the name of the links. Please help me to solve the query.
*** Settings ***
Library SeleniumLibrary
*** Variables ***
*** Test Cases ***
GetAllLInks
open browser https://tnreginet.gov.in/portal/ Firefox
Maximize Browser Window
${nooflinks}= Get Element Count xpath://a
Log To Console ${nooflinks}
@{linkItems} create list
FOR ${i} IN RANGE 1 ${nooflinks}+1
${linktext}= get text (xpath://a)$[i]
lOG TO CONSOLE ${linktext}
END
*** Keywords ***
Below I am getting the error
Started: E:\pycharm\projecttelegram\rautomation\alllinks.robot
==============================================================================
Alllinks
==============================================================================
[info] Opening browser 'Firefox' to base url 'https://tnreginet.gov.in/portal/'.
GetAllLInks 175
[info (+7.14s)] ${nooflinks} = 175
[info] @{linkItems} = [ ]
[info (+0.07s)] </td></tr><tr><td colspan="3"><a href="selenium-screenshot-1.png"><img src="selenium-screenshot-1.png" width="800px"></a>
[FAIL] Element with locator '(xpath://a)$[i]' not found.
| FAIL |
Element with locator '(xpath://a)$[i]' not found.
------------------------------------------------------------------------------
Alllinks | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output: E:\pycharm\projecttelegram\log\output.xml
Log: E:\pycharm\projecttelegram\log\log.html
Report: E:\pycharm\projecttelegram\log\report.html
Robot Run Terminated (code: 0)
There are just two minor typos in get text (xpath://a)$[i]
xpath:
out of brackets. (xpath:
-> xpath:(
$[i]
-> [${i}]
In total, the correct expression should be:
get text xpath:(//a)[${i}]