0
votes

I am trying to click a button/element on a popup window using Selenium2Library in Robotframework:

Click Element   name=OK

But I get the following error in Robotframework:

ValueError: Element locator 'name=OK' did not match any elements.

I Believe this is happening due to an ui-widget-overlay that does not disappear. Below are snippets from the html code, containing the Ok button and the ui-widget-overlay:

<button type="button" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">OK</span></button>

<div class="ui-widget-overlay" style="width: 1793px; height: 620px; z-index: 1005;"></div>

I know that I can successfully click element using xpath, but the xpath is dynamic in this case and I want to use a fixed value. Also, "Click Button" keyword did not work either.

Please let me know how I can go about this.

2
If the element child have not been clicked, the exception would be different - something in the line of "cannot click the element, as another one at coordinates would receive the click" - can't recall the exact wording. This one literally means Selenium cannot match such element in the DOM.Todor Minakov

2 Answers

0
votes

Have you tried looking at the class attribute of the button? To me it sounds like that might provide a more stable xpath or css reference. For example //button[contains(@class, 'ui-button')]

0
votes

You've misinterpreted the text of the button (OK) to be itsname attribute. An attribute is part of the XML/HTML tag, e.g. it should have been something like:

<button class="some values" name"OK">

, which it's not in the sample.

As you are looking for the particular button by it's visible text, this xpath locator would match it:

xpath=//button[span[@class="ui-button-text" and text()="OK"]]

The expression reads "match a button element having as a direct child a span with that class and text"