Unable to fetch the text from the grid in robot framework and selenium

Hi,
I am using Python-Robot framework-Selenium Library2. One grid is under testing. I want to fetch the value/text from first row of the grid and save to one variable. Text is something like ‘MM’. I have tried with all the xpaths. From robot framework I have used Get Text, Get Value, Get Element Attribute and all possible functions from selenium 2 library but it is not working.

Couple of examples of my tries;

  1. ${Code} = Get Text xpath=//*[@id="table"]/tbody/tr[${rows}]/td[22]
  2. ${Code} = Get Text //tr[@id='1b2-455']//td[contains(text(),'MM')]
  3. ${code} = Get Element Attribute xpath=//*[@id="table"]/tbody/tr[${rows}]/td[22] value

Any suggestion? Thanks !

First of: Selenium2Library is very much outdated, SeleniumLibrary is current, so please update to the most recent version.

Furthermore, please provide the results of what you tried. “it is not working” can mean many things, but without telling us what the exact response from the system is, there’s little we can do to help.

Thanks for your reply.

  1. I have around 155 Test Cases and now it is hard to make change in all the scripts to selenium library as it is asking for many changes across all the scripts. Will check it for now script development.
  2. For my current issue. The value ‘MM’ in a variable code and need to use it for further conditions but it is not saving anything and shwoing nothing in front of Code = .
  1. I have around 155 Test Cases and now it is hard to make change in all the scripts to selenium library as it is asking for many changes across all the scripts. Will check it for now script development.

A very good reason to prioritize upgrading as soon as possible. Upgrading will become harder and harder up until the point where it’s as good as impossible and you’ll have to start from scratch once libraries become unusable due to the world of browsers moving on.

  1. For my current issue. The value ‘MM’ in a variable code and need to use it for further conditions but it is not saving anything and shwoing nothing in front of Code = .

Please look at the TRACE logging and check what the return value for the Get Text and Get Element Attribute are. If those keyword calls don’t throw errors, the locators are resolved, so there should be a return value.

1 Like