I'm writing script to automate test where I've to select multiple rows from table & apply some settings to those rows (by selecting them in a group). For that, I'll have to select multiple rows from table, but I'm not able to select those rows using Selenium.

I tried it using following code (CTRL+select the rows), but it's not working -

$driver.action.key_down(:control).perform
$driver.find_element(:xpath, ".//*[@id='1']/div/div/table/tbody/tr[1]").click
$driver.find_element(:xpath, ".//*[@id='2']/div/div/table/tbody/tr[2]").click
$driver.find_element(:xpath, ".//*[@id='3']/div/div/table/tbody/tr[3]").click

Following are web contents -

<div id="abc" class="unselectable dataTable" emptylineuptext="Lineup is Empty" ...>
  <div class="xyz">
    <div class="def" style="min-height: 3024px;">
      <table class="buffer" style="margin-top: 0px;">
       <tbody>
        <tr id="1" draggable="true">
        <td>
        <td>NA</td>
        </td>   
        </tr>

        <tr id="2" draggable="true">
        <td>
        <td>NA</td>
        </td>   
        </tr>

        <tr id="3" draggable="true">
        <td>
        <td>NA</td>
        </td>   
        </tr>

        <tr>
        .
        .
        .
        </tr>
    </tbody>
  </table>
</div>

Manually, I can select multiple rows from table. Could someone please tell me the solution?

share|improve this question

25% accept rate
feedback

1 Answer

Try some thing like this.

$driver.action.key_down(:control).click("1st row").click("2nd row")..key_up(:control).perform

P.S : I don't know much about python selenium bindings. I hope above logic will gives you an idea.

share|improve this answer
feedback

Your Answer

 
or
required, but never shown
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.