0

I've been using Selenium with the product for a while.

Regular HTML pages, forms and javascript are working well with it.

Our developer just added an AJAX drop-down menu.

I can't 'record' that with selenium, how can I use it? Actually I can record that the control was initially clicked (which makes the drop-down appear) but not what option is then clicked. How can I then detect that they clicked on one of the options?

The HTML that's displayed is:

<ul id="fruit-switcher" class="nav nav-pills">
  <li class="dropdown">
    <a class="dropdown-toggle" href="#">
      Change fruit…
      <b class="caret"></b>
    </a>
    <ul class="dropdown-menu">
      <li>
        <a rel="nofollow" data-method="put" href="/admin/fruits/23-bananas/activate"></a>
      </li>
      <li>
        <a rel="nofollow" data-method="put" href="/admin/fruits/28-apples/activate"></a>
      <li>
      </li>
      <li>
        other options (a links)...
      </li>...
    </ul>
  </li>
</ul>
<script>

  //<![CDATA[
    $(function() {
      $('#fruit-switcher .dropdown-toggle').dropdown();
    })
  //]]>

</script>
1

2 Answers 2

0

You can always send_keys to the element.

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

Comments

0

Actually it was straight-forward selenium code:

click    link="Change..."
pause 200
click //ul[contains(@id,'fruit-switcher')]//ul[contains(@class,'dropdown-menu')]/li[3]/a
click    link="Change..."
pause 600
click //ul[contains(@id,'fruit-switcher')]//a[contains(text(),'Bananas')]

Comments

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.