Selenium can't click element obscure by "overlay" element - selenium

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

Related

NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//*[#id="card-id-oidc-i"]/a"}

I'm having this strange error (sometimes works sometimes does not):
no such element: Unable to locate element:
{"method":"xpath","selector":"//*[#id="card-id-oidc-i"]/a"}
My button has this:
<a href="/auth/realms/Global-Realm/broker/id-oidc-i/login?client_id=web&tab_id=Doz54nelUC0&session_code=gwAePmGfpQ2hBLommJO7Rswc1gNkB90Ctc4">
<div style="width:100%;height: 40px;">
<span class="arrow arrow-bar is-right"></span>
</div>
<div class="image" style="background-repeat: no-repeat;margin:auto; width:115px;height:120px"></div>
<div style="margin-top: 10px;min-width:170px">
<h4 style="text-align:center;"><b>log in</b></h4>
</div>
</a>
It's XPATH is:
//*[#id="card-id-oidc-i"]/a
I did this:
driver.findElement(By.xpath("//*[#id=\"card-id-oidc-i\"]/a")).click();
It is strange because sometimes works just fine but sometimes it fails.
Why?
You probably missing a delay.
Try using this:
WebDriverWait wait = new WebDriverWait(driver, 30);
wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[#id='card-id-oidc-i']/a"))).click();
BTW your locator is based on some parent element with id = card-id-oidc-i while you shared here only the child a element HTML.
Also, no need to put \ before " inside a String. You can simply use ' instead as I do here.
NoSuchElementException error may occur when :
HTML element may not be present in a DOM yet. So you have to implement WebDriverWait to wait until element is present and visible in a web page.
HTML element may not be inside frame or iframe.
Maybe in your case it is not in the DOM yet, try to wait until it is visible and on clickable position.

Webelement getText() function returns different values on the same element

Following code is used to get text of specified button element with id:
EE__printer-menu__activator
In our structure it's drop-down and here is element with child elements DOM structure:
<button data-v-12817ac3="" type="button" class="some classes" id="EE__printer-menu__activator"><div class="v-btn__content">
Printer
<i data-v-12817ac3="" aria-hidden="true" class="some classes">arrow_drop_down</i>
</div>
</button>
The problem is following: when drop-down is not expanded and I'm trying to get text of id="EE__printer-menu__activator" element using getText() I receive :
{Printer
arrow_drop_down}
which is expected. but when drop-down is expanded and I'm using the same I get only text of first child:
{Printer}
Can't understand why in this case getText() doesn't return "arrow_drop_down" text of the last child of selected element.
When drop down is not extended then if you pay attention
<i data-v-12817ac3="" aria-hidden="true" class="some classes">arrow_drop_down</i>
to more particular attribute aria-hidden is set to true. so when you are calling .getText on EE__printer-menu__activator, you are getting both the text.
Now, here is a bit assumption that when drop down is expanded, then aria-hidden value will be set to false. causing .getText() to return what it has, and it does have only first Printer.

How do I "get" an element from the HTML that is a "data-index" on Selenium IDE webdriver (Chrome)?

I want to do a click on somethink in a website, but the problm is that I get an error: Element <td style="">...</td> is not clickable at point (366, 304). Other element would receive the click: <div class="fixed-table-loading" but where I want to click, does not have a class, it only have's a data-index what can I use to "click" on it ?
You can use below css selector for finding that element,
tr[data-index='0']
However the error "Element <td style="">...</td> is not clickable at point (366, 304). Other element would receive the click: <div class="fixed-table-loading"" you are getting is not means that you doing false operation, it means that where selenium find your desired element to click, there is already a different element on that position and it will be getting that click.
So, first you need to focus on your element or if it is a member of a dropdown or opening list you need to first open that dropdown and then you should have click your element.

Toggle the element - Selenium

I am struggling with Selenium.
Basically I want to click on the following element to toggle the element:
<div class="btn-group pull-right">
<a class=" mr-2" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown-ddd" href="javascript:void(0)" onclick="$(this).closest('.btn-group').toggleClass('open');"
<svg class="">
<use xlink:href="resources/icons/settings.svg#Layer_1" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>
</a>
It changes to:
<div class="btn-group pull-right open”>
<a class=" mr-2" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown-ddd" href="javascript:void(0)" onclick="$(this).closest('.btn-group').toggleClass('open');">
<a class=" mr-2" aria-expanded="false" aria-haspopup="true" data-toggle="dropdown-ddd" href="javascript:void(0)" onclick="$(this).closest('.btn-group').toggleClass('open');">
<svg class="">
<use xlink:href="resources/icons/settings.svg#Layer_1" xmlns:xlink="http://www.w3.org/1999/xlink">
</svg>
</a>
The method I wrote for clicking this element:
WebElement dropDown = driver.findElement(By.xpath("//div[#class='btn-group.pull-right’]”));
dropDown.click();
However, I am getting an Exception:
no such element: Unable to locate element: {"method":"xpath","selector":"//div[#class='btn-group.pull-right']"}
Any recommendations on why I am geting this exception?
You can use 'or' logical operator in ur xapth which locate both.
Try this Xpath :-By.xpath("//div[#class='btn-group.pull-right’|//div[#class='btn-group pull-right open’ "]
your html shows element has class "class="btn-group pull-right" "
and your xpath "By.xpath(" //div[#class='btn-group.pull-right’]”" if i closely look at it your are adding dot in the xpath to remove space which is not required when using xpath, spaces will be removed by dot in css. So try using this xpath
//div[#class='btn-group pull-right’]

How do i make Selenium pull out the sidebar menu tree

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