5

I have a web app that I'm trying to write selenium tests for, and I have run into a problem with the Chrome driver. There is a wizard-type interface that users can employ to fill out a form. There is a button to add a row with a couple of settings. I have outlined this in black. The blue rectangle shows you the clickable area for the button. The middle of this rectangle is not overlapping anything else.

enter image description here

The problem is that there is a giant div that contains the whole screen and Chrome says that this div will get the click. So, how do I get around this? It doesn't seem like correct behavior that I can't click this button because there is a surrounding div tag. Almost nothing would be clickable if this were were proper behavior.

enter image description here

The button I want to click is this:

 <button id="add-thisSetting" class="btn">Add This Setting</button>

The surrounding div is:

 <div class="application-tour-overlay"></div>

Here is an abbreviated html source:

<div id="editBase">
  <div class="edit-buttons application_edit_controls">
    <div id="thingamajigSettings" class="application_thingamajig_settings">
      <div id="thisSetting" class="application_thissetting application-tour-spotlit">
        <div class="control-title">This Setting
        </div>
        <div class="thisSetting-block">
          <div>
            <div class="scrolling-table" style="overflow-y: auto; overflow-x: hidden;">
              <div class="add-thisSetting-bar">
                <div class="btn-group pull-right">
                  <button id="add-thisSetting" class="btn">Add This Setting</button>
                  <button class="btn dropdown-toggle" data-toggle="dropdown">
                    <ul class="dropdown-menu">
                </div>
              </div>
            </div>
          </div>
          <div id="rulescontainer" class="application_rule_view">
            <div id="settings">
              <div class="edit-buttons application_edit_controls">
              </div>
            </div>
          </div>
          <div id="app_notify_manager" class="application_notify_manager">
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<div class="identityOfMe-widget-ft"></div>
<div id="jstree-marker" style="display: none;"></div>
<div class="application_tour">
  <div class="application-tour-overlay"></div>
Selena
  • 2,208
  • 8
  • 29
  • 49

4 Answers4

1

Sometimes developer uses a full screen "div" to track actions, but Chrome webdriver cannot click anything when the "div" is shown and on the top. So you can use "z-index" attribute to hide it.

There is a example in C#: ((IJavaScriptExecutor)this.Driver).ExecuteScript("arguments[0].setAttribute('style', 'z-index: -1')", popup);

Yang Liu
  • 11
  • 1
0

try to use fire_event("click") instead of click ... it helped me.

Smern
  • 18,746
  • 21
  • 72
  • 90
Annet
  • 673
  • 1
  • 7
  • 17
0

There is a similar question [here] (Debugging "Element is not clickable at point" error) with a lot of information. I have had a similar problem where I was unable to click a button on modal that was already in the DOM, but hidden. Try this calling this function several times to see if the location of your button is changing from the JS.

public void PrintLocation()
{
Point point = driver.findElement(By.id("add-thisSetting")).getLocation();
System.out.println("X="+point.x+"Y="+point.y");
}

If this is the case, then you can fix it by sleeping until the button has stopped moving.

Thread.sleep(500);
Community
  • 1
  • 1
Clement Hoang
  • 675
  • 9
  • 18
0

One of my last resorts in cases like these (bad website design) is to resort to javascript modification of the DOM:

driver.execute_script(<<-javascript)
  var overlay = document.getElementById("modal_overlay");
  overlay.parentNode.removeChild(overlay);
javascript

For more thorough troubleshooting, you can take a look at my answer to a similar problem before for the general case: https://stackoverflow.com/a/23705280/234593

Community
  • 1
  • 1
Kache
  • 15,647
  • 12
  • 51
  • 79