I am using to try and select an in a menu, but there is no present. The website uses all JavaScript to enable the dropdown. The HTML code for the Bootstrap dropdown is shown below.

<div class="dropdown">
    <a class="no-disable dropdown-toggle" data-toggle="dropdown">
        <span class="glyphicon glyphicon-list"></span>
        <span class="add-item-text text-uppercase">Batch Management</span>
    <ul class="dropdown-menu text-uppercase">
            <a href="http://sqa.stackexchange.com/website/administration/foo" class="full-width text-uppercase" style="padding:4px 0px;">Foo</a>
            <a href="http://sqa.stackexchange.com/website/administration/foo2" class="full-width text-uppercase" style="padding:4px 0px;">Foo 2</a>
            <a href="http://sqa.stackexchange.com/website/administration/foo3" class="full-width text-uppercase" style="padding:4px 0px;">Foo 3</a>

The exception I am getting is an ElementNotInteractableException for the next element (the item in the list) which leads me to believe that Selenium is clicking on the dropdown menu (because it is clickable), however, it is not ready to actually dropdown the menu, and then when it tries to the member of the dropdown it fails because the menu never actually opened.

I have tried clicking the anchor element and both the span elements, and none of them open the dropdown. I have tried waiting for the element to be clickable for all of these solutions, as well, and none work. The only way I can get it to open the dropdown is by using Thread.sleep() which I would prefer to avoid. So, if anyone has any ideas for what explicit wait I need to use here, I am all ears.

Note: I can post the JavaScript files, but they are horribly organized (zero line breaks anywhere), so I won’t include them right now, but if anyone wants to try and sift through them, I can post them. I am not that familiar with JavaScript, so I don’t even know if they are that relevant to the problem

Edit: After some further research, it looks like there are some jQuery events that trigger after certain events. If I could use selenium to trigger these events, I think that would work, but I am even less familiar with jQuery than just Javascript. The relevant events are posted below
enter image description here

Edit 2: I also thought it would be useful for you guys to see Bootstrap’s documentation. So here it is

Source link https://sqa.stackexchange.com/questions/33723/how-to-reliably-click-bootstrap-dropdown-with-no-button-element


Please enter your comment!
Please enter your name here