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.
Related
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.
I've been trying to navigate through a webpage and testing the different links using Robot and Selenium.
I need to click several Dropdown menus. In Google chrome it works fine, but when I use Firefox there will always be one dropdown menu (not always the same one) that will appear selected (Like when a mouse passes over a button), but it will not get clicked.
The code I've been using:
Wait Until Element Is Visible //*[#id="Modules"]/a timeout=20s
Click Element //*[#id="Modules"]/a
Wait Until Element Is Visible xpath: //*[contains(text(), "Tasklist")] timeout=20s
Click Element xpath: //*[contains(text(), "Tasklist")]
This is the element HTML code:
<li id="Modules" class="nav-item nav-item-levels mega-menu-full show">
<a href="#" class="navbar-nav-link dropdown-toggle" data- toggle="dropdown" aria-expanded="true">
<i class="fa fa-lg fa-modx"></i>
<span class="menu-item-name" style="color: inherit; display: none;">Modules</span></a>
And this is the screen I'm trying to click on (In my test case, the "modules" dropdown menu appears selected, but the menu doesn't drop down)
Screenshot
So far I've tried increasing selenium_speed and adding a sleep command before clicking, but nothing seems to work.
Anyone knows what the problem with Firefox could be?
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')]"
Fyi: I'm using the selenium package for R, the selection code is equal to javascript or python so I'm asking a general selenium question.
I have a container which I have to make visible by a click, this works.
Then I try to select an element inside this container, I think I find it correctly but the click on the element only makes the popup window disappear.
Example code:
<div class="dateRanges" style="top: 275.313px; display: block;">
<a class="top dateOption CUSTOM" id="id32" href="javascript:;">
Benutzerdefinierter Zeitraum
</a>
<a class="dateOption TODAY" id="id33" href="javascript:;">
Heute
</a>
...
</div>
Element I try to find is "top dateOption CUSTOM".
My different tries which all failed:
remDr$findElement(using = 'xpath','//a[contains(#class,"top")]')$clickElement()
remDr$findElement(value = '//a[#class = "top dateOption CUSTOM"]')$clickElement()
remDr$findElements(using = 'css selector','a[class="top dateOption CUSTOM"]')[[1]]$clickElement()
I don't get any error message, the click seems to happen as the popup disappears, but the effect of the button does not.
I tried to save the object, wait a few seconds and click afterwards with no different effect.
I also tried different approaches with "idc4" with the same outcome.
Would appreciate any help, thank you.
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