How to click a menu items when menu item webelements are not available - selenium

I'm trying to click a menu item, however there are no webelements for the menu items.
When the menu items is not clicked the web element is shown as:
<button aria-expanded="false" aria-haspopup="true" aria-label="More actions" aria-setsize="2" aria-posinset="2" class="icon-only bolt-button bolt-icon-button enabled icon-only bolt-focus-treatment" data-focuszone="focuszone-226" data-is-focusable="true" id="__bolt-header-command-bar-menu-button10" role="menuitem" tabindex="0" type="button">
Once I click the menu item the Button tag changes. However the elements for the menu items are still hiddend.
Image of the menu and after click changes in span tag

click on the html tag and add break on subtree modification . Then click the menu and keep pressing f8 till the drop down is visible
Output:

Related

How to click on button when <input type =Button> using Selenium

How to click on button when input type is button , I am using below code, click on button is not working?
<p>
<img class="getdata-button" style="float:right;" src="/common/images/btn-get-data.gif" id="get" onclick="document.getElementById('submitMe').click()">
<input type="button" value="Get Results" tabindex="9" id="submitMe" onclick="submitData();" style="display:none" ;="">
</p>
I have tried
driver.find_element_by_css_selector("input[#type='button']")).click()
driver.find_element_by_id("get").click()
driver.find_element_by_id("submitMe").click()
also used xpath for both still nothing
It can be done through JavaScript if that is acceptable for you:
driver.execute_script("document.getElementById('submitMe').click()")
The <img> element fires an onclick event: onclick="document.getElementById('submitMe').click()"; it locates and clicks the <input> element button below in the DOM. The Selenium click interaction can be skipped and call the same JavaScript from the <img> element which should get you the desired result.

Selenium selector for checkbox pseudo-element

<label class="casllic_text" for="Checkbox">
::before
<span>Blob <a class="button link" href="abc.pdf">Terms</a> </span></label>
I want to click on checkbox.
If I use label[for="Checkbox"] as selector, webdriver clicks on Terms link which opens PDF in another tab.
How can I click on checkbox which so far only gets identified if I hover on ::before. (Used inspect element to do that)

Unable to locate the element after clicking on toggle button

I am trying to automate the assignment for toggle button on the below link :
http://way2automation.com/way2auto_jquery/accordion.php
where the icons will go on and off based on the toggle button.
The HTML code snippet for the buttons are :
<h3 class="ui-accordion-header ui-state-default ui-accordion-icons ui-corner-all" role="tab" id="ui-id-1" aria-controls="ui-id-2" aria-selected="false" aria-expanded="false" tabindex="-1"><span class="ui-accordion-header-icon ui-icon ui-icon-circle-arrow-e"></span>Section 1</h3>
I have switched to the frame already and trying to check the element using :
chromeDriver.findElement(By.xpath("//*[#id=\"ui-id-1\"]/span")).isEnabled()
however after clicking on toggel buttons the icon gets disappeared and the element is not visible at all. Hence I am getting error for the above line. Is there any way to check the icons are there or not?

Twitter bootstrap dropdown show/hide events how do they work

I am trying to understand how the show/hide logic of a dropdown in twitter bootstrap works.
I can declare a dropdown menu in a navbar purely with HTML, and yet it seems that Javascript is involved with showing/hiding the dropdown. Also the dropdown disappears if I focus out by clicking on an unrelated area on the page.
Question part 1: Where can I find the Javascript code that is involved with Dropdowns in bootstrap?
Question part 2: Is it somehow possible to tap into the event logic and execute some custom Javascript code when a certain dropdown receives a focus out event? For example so that I can hide another (unrelated) element on the page when the dropdown looses focus?
To be more precise:
Lets say I declare a bootstrap dropdown purely in HTML (this would be inside a ul.nav.navbar-nav):
<li role="presentation" class="dropdown">
<a id="mainmenu" class="dropdown-toggle" data-toggle="dropdown"
role="button" aria-haspopup="true" aria-expanded="false">
Lectures <span class="caret"></span>
</a>
<ul class="dropdown-menu">
<li>Action</li>
</ul>
</li>
Now somewhere else on the page I have the following HTML:
<div id="#background" style="display: none">
<img src="...">
</div>
When I click on the dropdown button bootstrap will show the dropdown, but want two additional things to happen:
The div#background should be shown
Assuming I click somewhere outside the dropdown (which will cause bootstrap to close it), I want the div#background to be hidden again.
I think it should somehow be possible to register my own callback function on some bootstrap event and show/hide my div from that callback, like so:
/* just to illustrate my idea */
hide = function(element) {
element.style.display = "none"
}
show = function(element) {
element.style.display = "block"
}
}
So how and where could I register the hide and show functions such that they get called when I open/close the dropdown and also when I click on an unrelated area on the screen, which will cause the dropdown to close.
If this is possible to achieve purely in HTML by attaching some data-* elements to my div#background then I would like to know about that too.
First:
Do you think about something like this?
$('.dropdown-toggle').dropdown();
Got it from w3schools.com
Second:
You can do call the dropdown link
$('#element').click( function(){
$('#dropdownElement').dropdown();
});
Is that what you are looking for?

Customer dropdown click using Selenium

I have drop down which is basically a div that is displayed in a block, When I click on a button. Each value/item in a drop down is div. Dropdown value is something like this "Click to view report <img-help>". Now my question is when i try to open the drop down and click on a item, i see that sometime <img-help> is clicked and the test is failing as clicking on image will open a help window and it is not actually selecting the item in the dropdown. How can avoid this and just click on the text?
I basically click on the button and parse through the list and then click on the value that matches on what I want to click using Selenium Java api.
updating the code that i am trying to click I am trying to click "XXXXXXXYYYYYYXXXXXX" in the div. which will refresh the page with new data.
Also wanted to mention that I am doing this in IE7. Firefox seems to be working fine.
<div class="mstrListBlockItemSelected" title="Evaluate charges to identify potential for improvement.">
<div class="mstrListBlockItemName" style="padding-left: 25px;">
XXXXXXXYYYYYYXXXXXX
<span style="width: 4px;"/>
<img style="width: 16px; height: 16px; cursor: pointer;" alt="Help" src="../plugins/custom/images/help.gif"/>
</div>
</div>