0

Here is my code:

<div class="table row column" xpath="1">
    <div class="table__head">
      <div class="table__row">
        <div class="table__cell sys-log__col-wrapper sys-log__col-id">
          <div class="column small-2 sort_button_wrapper">
            <button class="sort-ascending" ng-click="sortBy('Id', false)"></button>
            <button class="sort-descending" ng-click="sortBy('Id', true)"></button>
          </div>
          ID
        </div>
        <div class="table__cell sys-log__col-wrapper sys-log__col-desc">Description</div>
      </div>
    </div>


${xpath_1} = //div[@class="table__row"]/div[1]
${xpath_2} = //div[@class="table__row"]/div[2]

I need to get ID as output for xpath_1 and Description as output for xpath_2. but when I try to get output for below code I am getting:

${table_data}=  Get Table Cell  ${xpath_1}

The following error I am getting for this method

Keyword 'SeleniumLibrary.Get Table Cell' expected 3 to 4 arguments, got 1.

(or)

${table_data}=  Get Text  ${xpath_1}

empty space is coming as output for this method

Please suggest me how to get ID and Description as output from the above table using robot framework.

Salvatore
  • 10,815
  • 4
  • 31
  • 69
  • I'm not expecting `Get Table Cell` to work given that there is no `
    ` involved in the html. Based on the [documentation](https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html#Get%20Table%20Cell) it also provided information on the other attributes it requires. Have you tried `Get Text` or `Get Value` to directly retrieve them?
    – A. Kootstra Aug 20 '20 at 06:58
  • I have tried with Get Text and it returns empty space and for Get Value i am getting None – Ganesan Baskar Aug 20 '20 at 10:58
  • Can you add the exact command you've tried to your question via the [edit] functionality? That way we have a better understanding what is going on. – A. Kootstra Aug 20 '20 at 16:00

1 Answers1

0

Using the example as a basis I've been unable to replicate your problem because when using Get Text keyword actually provides the desired ID value. Below are the files and approach for replicating this in your own setup.

Create a new file:

div_value.html

<html>
<body>
<div class="table row column" xpath="1">
    <div class="table__head">
      <div class="table__row">
        <div class="table__cell sys-log__col-wrapper sys-log__col-id">
          <div class="column small-2 sort_button_wrapper">
            <button class="sort-ascending" ng-click="sortBy('Id', false)"></button>
            <button class="sort-descending" ng-click="sortBy('Id', true)"></button>
          </div>
          ID774747474
        </div>
        <div class="table__cell sys-log__col-wrapper sys-log__col-desc">Description</div>
      </div>
    </div>
 </div>
 </body>
 </html>

In the directory where this file goes execute the following command:

python -m http.server 8989

I use RED, but other IDE's or text editors will work too. Create a robot file

div_value.robot

*** Settings ***
Library    SeleniumLibrary    

*** Variables ***
${xpath_1}     //div[@class="table__row"]/div[1]
${xpath_2}     //div[@class="table__row"]/div[2]

*** Test Cases ***
Retrieve DIV Value
    
    Open Browser 
    ...    url=http://127.0.0.1:8989/div_value.html
    ...    browser=headlesschrome

    # ${table_data}=  Get Table Cell  ${xpath_1}
    ${table_data1} =  Get Text   ${xpath_1}
    ${table_data2} =  Get Value  ${xpath_1}
    No Operation
    [Teardown]    Close All Browsers

Using the debugger in RED I paused on the No Operation keyword line.

enter image description here

A. Kootstra
  • 6,827
  • 3
  • 20
  • 43