0

I am at a loss with the following and maybe the code needs to be changed, but I'll ask here first and hopefully someone will be able to assist.

I have a long form with multiple choice questions. eg.

Q1 to Q30 - each answer is a radioButton named "OK", "not OK", "Don't Know" now running queries on the IRB console as: Query("radioButton") and query("FormsTextView") I get the contentDescription and the text values.

Now, due to the way the form data is generated (via Xamarin forms) each question has: Q1 - text = ok, not ok, don't know. contentDesciption is one per question.

So, asserting on the text is not an option, and asserting on the contentDescription will only select the first radioButton.

asserting on ID is not an option as these are generated at run time by xamarin.

So what I am looking for is a way to see if a radioButton has been selected then select a different one.. eg. if 'ok' is selected, then select 'not ok' (note, both have same contentDescriptions, so maybe select 2nd instance of contentDesciption may work, however I am not that versed in Ruby as yet to write a custom step definition that would handle this scenario.

A probable solution may also be: Then I touch textAndContent text - with a step def's pseudo code of " Then I touch the "textNameOfButton" == "contentDescription" do touchElement where textNameofButton -- contentDescription so basically the custom step takes an input of text and contentDescription and passes those to a compound query, only then performing the tap_when_element_exists method. not idea how to do this sadly :(

Any help or pointers is most appreciated.

Thank you in advance. G

Graeme Phillips
  • 131
  • 1
  • 1
  • 10

1 Answers1

0

As I understood you you will have 30 buttons with "OK", 30 with "Not OK" and 30 with "Don't know".

I would query for each kind and place output i an array. Something like this (for OK):

okArray = query "radioButton text:'OK'

Then look at index 0 in all 3 arrays to see which one is selected. And then just select a different one. And then do the same for each of the other indexes.

Lasse
  • 1,153
  • 1
  • 10
  • 21
  • so something like: okArray = query("radioButton", :text) //repeat x 3 etc. there may be an issue as I am using a samsung gal S3, and the irb queries only return what is visible on the device screen at one time. so the array values would change. – Graeme Phillips Jun 10 '15 at 10:45
  • Yes something like that. Yes you might run into a more complex scenario if you can only get part of the 30 in 1 query. However you might be able to solve it by first doing this for the items you can see on screen (and query) and then use scroll_to to get a "new set" buttons on screen and then run part 1 again. – Lasse Jun 10 '15 at 18:28
  • how do I scroll_to lasse? – Graeme Phillips Jun 11 '15 at 08:11
  • wait_poll(:until_exists => "label text:'#{name}'", :timeout => 20) do scroll("tableView", :down) end. Copied from http://stackoverflow.com/a/16436739/1165581 by http://stackoverflow.com/users/634678/chathura-palihakkara – Lasse Jun 11 '15 at 12:55