0
votes

I need to use Selenium to automate a test, where there's check boxes, drop downs, and text boxes. Drop downs are currently a problem. It seems the problem is Selenium can't identify the element from my recording. I've researched the topic and can't find any solutions that don't involve extensive coding. For work purposes, I can only use the IDE.

I tried the last solution in this: Selecting a drop-down option using Selenium IDE

but it didn't work. I've tried click, select, and sendkeys commands. The best command seems to be click, where it clicks the drop down and it displays the options. I can't figure out how to select the option. When I click on the drop down, I get the following in Selenium:

xpath=(//button[@type='button'])[15]

After clicking the option:

//div[12]/div/ul/li[7]/a/span

After using firebug, I see that the drop down code is:

<button class="btn dropdown-toggle selectpicker btn-default" type="button" data-toggle="dropdown" title="--Select Value--">

How do I do this? When I've executed smaller tests for only a drop down, it works and then the next day after I execute it in a larger test it fails.

1

1 Answers

0
votes

I am missing some details from explanation, but sounds like your drop-down is not a real drop-down, it's rather a button, which on click shows a div with bunch of links, on which you are supposed to click. So I suggest something like this:

  1. Click the button.

    Command: click
    Target: xpath=(//button[@type='button'])[15]
    
  2. Wait for //div[12]/div/ul to show up.

    Command: waitForVisible
    Target: //div[12]/div/ul
    
  3. Select the option by clicking on link:

    Command: click
    Target: //div[12]/div/ul/li[7]/a/span
    

Note: In all above cases I used xpath you provided in question, but in reality avoid using indexes, and rather see if that path can be identified by some attributes, e.g. @id, or @class. It applies to button, ul and everything else. Indexes are the worst possible way to find elements really, and should only be used if nothing else is possible (which usually is not true, for example button will always have label)