1

I'm working with Selenium Webdriver using ruby.

I have a dropdown and after each value/text selected inside it, I want to extract that value/text visible on webpage interface without html tags, because for that value selected, in div > option tag I do not have a specific attribute for it, to figure out which is the value, can I do that in selenium webdriver using ruby?

Edit : HTML code :

<select name="OwningAndUsingCarPanel.UseOfVehicle" id="OwningAndUsingCarPanel_UseOfVehicle" autocomplete="off">
  <option value="0" selected="selected">Please select</option>
  <option value="227">Social only</option> 
  <option value="228">Social including commuting to a single place of work</option> 
  <option value="229">Business use by you</option> 
</select>  

UPDATE - more details:

I've tried this method and it's working if you select previous some value, but in my case I have some bug in my dropdown values, something like this: have 5 dropdowns one after another, and each of them is depending on the previous dropdown, so if i begin to fill the form like this:

1). select value at first dropdown (take the text)

2). select at the second dropdown some value (take the text)

3). select at the third dropdown some value (take the text)

4). select at the fourth dropdown some value (take the text)

5). select at the fifth dropdown some value (take the text) (this dropdown is generated by the previous fourth dropdowns values) - now the second value of dropdown is changed on the interface webpage. (so here I cant put element.text for the second dropdwon because it extract the value I have selected point 2).

I want to check if after each selecting value the previous value remain the same on the webpage inteface, in my case I have some bug at this.

4
  • could you please share the html for the dropdown and what is the expected text you want to extract Commented Jun 2, 2016 at 7:09
  • Here is html code: <select name="OwningAndUsingCarPanel.UseOfVehicle" id="OwningAndUsingCarPanel_UseOfVehicle" autocomplete="off"><option value="0" selected="selected">Please select</option> <option value="227">Social only</option> <option value="228">Social including commuting to a single place of work</option> <option value="229">Business use by you</option> </select> If for example I select the first option, no extra attribute is in place after that(eg:selected="selected"), just after click sumbit. Commented Jun 2, 2016 at 7:29
  • please add this to the question itself. Commented Jun 2, 2016 at 7:34
  • can you look at my UPDATE, please. Commented Jun 2, 2016 at 13:16

2 Answers 2

1

You can get the value of the textfield using attribute :

element['value']

For any other element you can get the text using :

element.text
Sign up to request clarification or add additional context in comments.

1 Comment

I have tried this ones, but with no success, can you see my last update.
0

You can just do element.text to get the display value of an element.

1 Comment

I have tried with this, but it is not working for me, can you see my last update.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.