I have a iframe-sidebar which appears as soon as a widget is hovered over , since it uses the onchange javascript event, and hides back when the sidebar is clicked again. There is a listbox in this sidebar which needs to be clicked for my chain to continue. How do i program Selenium webdriver in Python to pull out this sidebar ?
Thanks
On reading answers to question, I added this :-
element = driver.find_element_by_xpath('//*[#id="leftSiderBarForm:moduleMenu"]')
element = driver.find_element_by_id("leftSiderBarForm:moduleMenu")
hover = ActionChains(driver).move_to_element(element)
hover.perform()
but get error :-
MoveTargetOutOfBoundsException: Message: u'Offset within element cannot be scrolled into view: (72.5, 8.5): [object XrayWrapper [object HTMLSelectElement]]' ;
This is the HTML of that element that i copied from Chrome. I changed actual values to ABC and so on.
<select id="leftSiderBarForm:moduleMenu" name="leftSiderBarForm:moduleMenu" class="comboboxnowidth leftSideMenuSelect " size="1" onchange="jQuery('.submitMenuSelection').click()" style="z-index: 0;"> <option value="">-- Select --</option>
<option value="ABC">abc</option>
<option value="DEF">def</option>
Could i use Javascript to trigger that Jquery ?
from selenium.webdriver.common.action_chains import ActionChains
def hover_over_item(self):
driver = webdriver_connection.connection
element = driver.find_element_by_id(locator)
hover = ActionChains(driver).move_to_element(element)
hover.perform()
Reference
Related
selenium.common.exceptions.ElementClickInterceptedException: Message: Element <select id="buttonmodule" class="x2j" name="buttonmodule"> is not clickable at point (437,425) because another element <div id="overlay" class="r1_hide_busy_status r1_show_busy_status"> obscures it
Message: Element <select id="buttonmodule" class="x2j" name="buttonmodule"> is not clickable at point (437,425) because another element <div id="overlay" class="r1_hide_busy_status r1_show_busy_status"> obscures it
I tried to find element id="buttonmodule" to click but I got message that it is not clickable by overlay element
XPATH of buttonmoduel: "//a[contains(text(),'buttonmodule')]
info of overlay: <div id="overlay" class="r1_hide_busy_status" style="height: 967px; width: 1853px;" xpath="1"></div>
According to my perception, your selected element is a dropdown developed using the select tag. Basically dropdown is developed using select tag will work by using selectByVisibleText() or selectByValue() or selectByIndex() methods as these are default methods to select values in the dropdown.
And we need to locate the dropdown and pass that object reference as an argument for select class nothing but associating both.
For example:-
Webelement dd =
driver.findElement(By.xpath("//div[#id='buttonmodule']"));
Select s=new Select(dd);
s.selectByVisibleText("2");
I have button in our website, and border areas of the button is not clickable. So, i need to make sure the button is getting clicked at the center. Is it possible via selenium?
I tried using coorinates, but it is not recommended for our scenario.
xpath used : //div/button[#id='clickme']
<div class="col-lg-10 col-sm-12 p-0 pt-4">
<button class="click mb-3 " tabindex="0" id="clickme">+ Click Here</button>
</div>
Java code used to click
WebElement button = driver.findElement(By.id("clickme"));
button.click();
I guess the click is happening sometimes[2 out of 10 times] on the border where it is not clickable(hand symbol not shown) . As a result report says the click action happened, but there is no event fired on the website.
To identify the element with text as Click Here you can use either of the following Locator Strategies:
cssSelector:
"button.click#clickme"
xpath:
"//button[contains(#class, 'click') and #id='clickme'][contains(., 'Click Here')]"
This question already has answers here:
Element MyElement is not clickable at point (x, y)... Other element would receive the click
(5 answers)
Closed 3 years ago.
I try to select checkbox via chrome webdriver, but always get error like "Element is not clickable at point (x, y)". I use the latest ChromeDriver 2.35. Thanks for help!
Here are the calls I have tried"
driver.findElement(By.xpath("/html[#class='ng-scope']/body[#class='layout-default']/main[#class='container']/form[#class='form-horizontal ng-pristine ng-valid ng-valid-required']/div[#class='row ng-scope']/div[#class='col-md-7']/div[#class='panel panel-default ng-scope']/div[#class='panel-body'][1]/div[#class='list-permission'][1]/div[#class='checkbox'][1]/label")).click();
OR
driver.findElement(By.cssSelector("input[value='platform:AccessWebsite']")).click();
OR
driver.findElement(By.xpath("//input[#value='platform:AccessWebsite']")).click;
Here is the snippet of html source
<h2>Main Platform</h2>
<div class="list-permission">
<div class="checkbox">
<label>
<input name="Policy[0][Action][]" type="checkbox" value="platform:AccessWebsite">
Access to the website
</label>
</div>
.......
When the element is not in a visual portion of the screen, then we will get element not clickable exception. The solution for this is moving the cursor to that element or scrolling the screen.You can use Actions class to move to that element or javascript executor for scrolling. try the below code and let me know.
WebElement element=driver.findElement(By.xpath("/html[#class='ng-scope']/body[#class='layout-default']/main[#class='container']/form[#class='form-horizontal ng-pristine ng-valid ng-valid-required']/div[#class='row ng-scope']/div[#class='col-md-7']/div[#class='panel panel-default ng-scope']/div[#class='panel-body'][1]/div[#class='list-permission'][1]/div[#class='checkbox'][1]/label"));
Actions act= new Actions(driver);
act.moveToElement(element).click().build().perform();
This should work as expected.
Note: some browsers may not support actions class, in such case i suggest you to scroll the screen and perform click.
Again, this question might be easy or already asked but i am not able to find any answer to this. All i get is to check if element is clickable but that is not working for me.
Is there any simple solution to wait for an element until it becomes enabled. I have set of dropdowns in my application and other dropdown get selectable only when value is selected in previous dropdown.
I tried below code but it is not working.
var element = element(by.css('[id*="uxSeries"] select'));
browser.wait(protractor.ExpectedConditions.elementToBeClickable(element), 10000);
Error message i am getting:
Failed: stale element reference: element is not attached to the page
document
HTML for dropdown before it get enabled:
<select name="GalleryControl$uxSeries" onchange="OnChangeScript" id="uxSeries" disabled="disabled" style="width:215px;">
<option selected="selected" value="">All Series</option>
<option value="Value1">Option1</option>
<option value="Value2">Option2</option>
<option value="Value3">Option3</option>
<option value="Value4">Option4</option>
<option value="Value5">Option5</option>
</select>
After i select value in my first dropdown, disabled="disabled" property goes away from dropdown.
Can i wait for browser until it is enabled or Disabled property is no more?
Failed: stale element reference: element is not attached to the page document
This exception occurred due to changing of element, as you are saying I have set of dropdowns in my application and other dropdown get selectable only when value is selected in previous dropdown means when it's getting enable, it changes their position or some attribute value may be disabled attribute become change that's why you're in trouble.
You should try first to wait until this element become stale from disabled state using protractor.ExpectedConditions.stalenessOf(), then find again this element when it is in enable state as below :-
var EC = protractor.ExpectedConditions;
#find disabled select element first
var disabledSelect = element(by.css("select#uxSeries[disabled='disabled']"));
#now wait until this becomes stale from disabled state
browser.wait(EC.stalenessOf(disabledSelect), 10000);
#now find enabled select element
var enabledSelect = element(by.css("select#uxSeries"));
#now do your further steps
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Selenium WebDriver - hidden select and anchor
Before I post my question I just want to tell that I am new to Selenium..
I am trying to select an option from a dropdown. The options display when clicked on the down arrow in the dropdown box. But, when checked in the Firebug, the display style was "none" and when trying to select the option using JUnit webdriver code by using click method in Eclipse, it did not work and it gave the exception - "org.openqa.selenium.ElementNotVisibleException: Element is not currently visible and so may not be interacted with".
Please refer to the attached image for the dropdown and HTML tags.
<select class="size-dropdown mediumSelect selectBox" name="skuAndSize" style="display: none;">
<option value=""></option>
<option value="2545672:S" name="skuId"> S</option>
<option value="2545673:M" name="skuId"> M</option![enter image description here][1]>
<option value="2545674:L" name="skuId"> L</option>
<option value="2545675:XL" name="skuId"> XL</option>
<option value="2545676:XXL" name="skuId"> XXL</option>
<option value="2545677:XXXL" name="skuId"> XXXL</option>
<option value="2545678:XXXXL" name="skuId"> XXXXL</option>
</select>
I looked at this link before posting this question - Selenium WebDriver - hidden select and anchor
But, since I am just starting I am not able to understand clearly.
Note: The same worked in IDE when used clickAt method. But in Webdriver the clickAt method is not present. Can anyone help me in this. Thanks!
Well the matter is Selenium is unable to interact with invisible ( disabled) elemnts. So you need to make element visible. BAsic idea: to make dropdown roll down , then wait with driver.manage.timeout(...) and then click on the appear needed element in dropdown.
Or you can use javascript to click element directly without preceeding dropdown roll down. Js is able to cope with it.
So this approach ALWAYS works:
css1=select[class="size-dropdown mediumSelect selectBox"]>option[value=""]
css2=select[class="size-dropdown mediumSelect selectBox"]>option[value="2545672:S"]
css2=select[class="size-dropdown mediumSelect selectBox"]>option[value="value="2545673:M"]
//.... and so on.....
public void jsClickOn(String cssSelector){
JavascriptExecutor js = (JavascriptExecutor) driver;
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("var x = $(\'"+cssSelector+"\');");
stringBuilder.append("x.click();");
js.executeScript(stringBuilder.toString());
}
jsClickOn(css1);
jsClickOn(css2);
jsClickOn(css3);
Another way:
using actions builder, advanced user actions API. You can read about it here And code will be smth like that:
WebElement mnuElement;
WebElement submnuElement;
mnEle = driver.findElement(By.Id("mnEle")).click();
sbEle = driver.findElement(By.Id("sbEle")).click();
Actions builder = new Actions(driver);
// Move cursor to the Main Menu Element
builder.moveToElement(mnEle).Perform();
// Giving 5 Secs for submenu to be displayed
Thread.sleep(5000L);
// Clicking on the Hidden SubMenu
driver.findElement(By.Id("sbEle")).click();
But also pay attention on the way how you found css selectors, xpaths verifying it in e.g. firepath, addon to firebug in ffox.
Hope this helps you)
See this screen as example of locating dropdown options.