Selenium selector for checkbox pseudo-element - selenium

<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)

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.

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

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:

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?

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>

I can't get selenium webdriver to recognize elements on a modal that fades in

I'm testing a form. When I click on a modal, a div modal appears and the background fades out and this new modal fades in that allows you to input information. For some reason selenium won't recognize elements on this modal. Its not listed as an iframe so I'm not sure if I'm suppose to use the switch to.
the modal
<div id="addressModal-20f95ac4-8a83-4c02-862d-a42d60a74b04" class="modal hide fade in"
style="display: block;" aria-hidden="false">
text are in modal
<textarea rows="2"name="viewModel.MortgageForm.BorrowerInformationSection.Borrowers[0].Dependents.modalTextArea-addressModal-20f95ac4-8a83-4c02-862d-a42d60a74b04" id="modalTextArea-addressModal-20f95ac4-8a83-4c02-862d-a42d60a74b04" cols="20" class="span valid"></textarea>
There may be multiple elements with that same DOM signature and webdriver picked up the one which is not context of the current user view.
Solution: Since it is not an iframe, you will have to locate the element in context of the modal box container. You can try the following to locate the textarea webelement:
JQuery:
$("div[id^='addressModal']:visible").find("textarea")
WebDriver(Java):
driver.findElement(By.cssSelector,"div[id^=addressModal] textarea")