Actions.MoveToElement donot move focus to element beyond the scrollable visible of browser having Chrome 61 Webdriver 3.5.3 and chrome driver 2.31
Meta -
OS: Windows 7 - 64 b Selenium Version: 3.5.3, Browser: Chrome 61, 64 b? Chrome driver: 2.31
Expected Behavior - Focus move to an element scrolling the page up or down, where ever in a scrollable browser page.
Actual Behavior - Error 'Element is not clickable at point (,)'
Steps to reproduce -
Actions mouseOver=new Actions(rwd); mouseOver.moveToElement(remoteWebElement.findElement("//XpathOfElement")). build(). perform();
For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.
See CONTRIBUTING.md
This also yields the same result when trying to click on an element outside the current visible part of the page.
Can confirm it worked fine before the most recent Chrome update.
Yes, correct. Mouse click and Actions.moteToElement were working fine with Chrome V60 , 64bit. Let me rewrite the reproducible step.
- An element in webpage which could be scrollable down or up.
- Element could be a link, or a table (button), or a dropdown.
- Before action (click or select from dropdown), the Actions.moveToElement() is called to 've the focus to object to operate on.
For issues please provide a concise reproducible test case and describe what results you are seeing and what results you expect.
Don't use narration. Write code.
Try this below code in chrome, firefox, IE browser. But somehow the code is not getting worked. Even though it written properly. It seems like action class is no longer supported by selenium.
In my below code requirement is like I have to hover Main menu "Campuses", After hovering Campuses, sub-menus will be displaying, So, from the sub-menus, I want to click on "Chennai".
See the below attached code for more details.
I am using selenium - 3.5.3 Google Chrome Driver - 2.31 Operating System - Windows 8.1
System.setProperty("webdriver.chrome.driver", "D:\\Jainish\\RND\\Drivers\\chromedriver.exe");
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.get("http://www.amity.edu/");
System.out.println(driver.getTitle());
WebElement main_menu = driver.findElement(By.xpath("//ul[@class='megamenu main-nav']/li/a[text()='Campuses']"));
WebElement child_menu = driver.findElement(By.xpath("//ul[@class='megamenu main-nav']//li/a[text()='Chennai']"));
Actions act = new Actions(driver);
new WebDriverWait(driver, 60).until(ExpectedConditions.visibilityOf(child_menu));
act.moveToElement(main_menu).moveToElement(child_menu).click().build().perform();
Can anyone update me regarding this issue?
This sample can't work because
new WebDriverWait(driver, 60).until(ExpectedConditions.visibilityOf(child_menu));
never succeed, child menu is not visible until you move mouse over main menu item.
You have to change the order of instructions:
act.moveToElement(main_menu).perform();
new WebDriverWait(driver, 60).until(ExpectedConditions.visibilityOf(child_menu));
act.moveToElement(child_menu).click().perform();
This code works for me.
The main issue was that, in a scrollable page , moveToElement(), cannot set focus to element which is below of above the visible area. ie, the page has to automatically set focus on the element.
The solution provided by 'barancev' should work, unless the parent has to be scrolled to make it visible.
The issue is not fixed. Cud u please reopen it.
@SwastikGanguly Sorry, I did not catch that it was not your sample of code
Can you please provide me solution of this question.
@jainishkpd Please send questions to the selenium user group
@SwastikGanguly Please provide a concise reproducible test case and describe what results you are seeing and what results you expect.
I guess there is some issue with Actions methods, it is not set focusing the right element. As we can see from comment of 'matt-shepherd', also webdriver.click is not setting focus to right element. Question is where is the issue - is it the webdriver 3.5.3? or is it in library of selenium java 3.5.3?
@SwastikGanguly Please provide a concise reproducible test case and describe what results you are seeing and what results you expect.
It's too early to make guesses. We can't discuss an issue unless we can reprodice it.
Also take note that moveToElement does not autoscroll, it's a design restriction at present.
Scrolling in Actions should be implemented in W3C WebDriver level 2, see https://github.com/w3c/webdriver/issues/1005
Yes, it clearly mentioned in the question (Selenium 3.5.3) with all latest browsers and with all latest drivers of respective browsers.
Now it points to right direction. Thanks. Let the issue open till level 2 completion, and build and release. Once we get back the moveToElement i would recomment a closure of issue. Is that ok?
@SwastikGanguly We'll close the issue unless you provide a concise reproducible test case.
If it's related to https://github.com/w3c/webdriver/issues/1005 -- there is no need to keep it open here, the issue should be raised on driver vendor specific trackers.
If it's not related to https://github.com/w3c/webdriver/issues/1005 -- what's the purpose to keep it open at all?
To repo the .Click() below the scroll issue:
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.bbc.co.uk");
driver.FindElementByClassName("orb-footer-terms").Click();
Expect the browser to navigate to "http://www.bbc.co.uk/usingthebbc/terms/"
Actual result is an exception:
System.InvalidOperationException : unknown error: Element is not clickable at point (457, 9020)
(Session info: chrome=61.0.3163.79)
(Driver info: chromedriver=2.31.488763 (092de99f48a300323ecf8c2a4e2e7cab51de5ba8),platform=Windows NT 10.0.15063 x86_64)
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebElement.Click()
Used to work in prior version of Chrome.
Current horrible work around:
var driver = new ChromeDriver();
driver.Navigate().GoToUrl("http://www.bbc.co.uk");
var element = driver.FindElementByClassName("orb-footer-terms");
driver.ExecuteScript("arguments[0].scrollIntoView()", element);
element.Click();