2

I am using Appium and Cucumber with Ruby to carry out some UI tests on our application. I want to use the code below to select a button, with the same name but found in two different cells, for example cell 1 and cell 2. I do not want to use Xpath for this, I would really prefer to stick to using name.

Then(/^I click 'Like' on first file$/) do find_element(:name, "Like").click end

Then(/^I click 'Like' on second file$/) do find_element(:name, "Like").click end

Does anybody have any ideas on how to achieve this? Using each of these lines of code will only interact with the first button, and I would like a way to be able to interact with any of the 'Like' buttons in the Table Cells without resorting to Xpath.

Thanks in advance!

1 Answer 1

2
find_elements(:name,"Like")[0].click
find_elements(:name,"Like")[1].click
...

button(1).click
button(2).click
...

ele_index(:UIAButton,1).click
ele_index(:UIAButton,2).click
...

buttons[0].click
buttons[1].click
...
3
  • Could you add some explanation to your answer, explaining how this helps the poster?
    – Kate Paulk
    Mar 17, 2015 at 10:48
  • Indeed for programmers this will make sense, but maybe not for testers with only very basic programming skills. Mar 17, 2015 at 15:19
  • Those are the ruby alternatives with appium to achieve what user asked. He already mentioned find_element(:name, "Like").click so he his familiar with appium/ruby. Hope my answer help others. Mar 18, 2015 at 11:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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