battleship battleship - 3 months ago 33
Ruby Question

how to double-click on a cell in table with Selenium Ruby Webdriver

I'm trying to use below codes to double-click on a cell in a table in my web application (I tried to do Click two times with the hope that they are equal to double-click). However, the cell is not clicked at all, but I expect that after double-clicking on the cell, the text field will be displayed for me to edit info of that cell.

@driver.find_element(:xpath => "//table[@id='gridabc']//tr[1]/td[9]").click
@driver.find_element(:xpath => "//table[@id='gridabc']//tr[1]/td[9]").click


I'm using Selenium Ruby Webdriver. Please help guide me a way to resolve this. Thanks much.

Answer
#@example Double click an element

el = driver.find_element(:id, "some_id")
driver.action.double_click(el).perform

Code shamelessly copied from the documentation :)

Comments