Reputation: 489
Here are the details of my Development Environment:
Visual Studio 2012 Ultimate with Update 4 Google Chrome Version 38.0.2125.111 m Windows 7 Professional with 32-bit Operating System Coded UITest Builder 11.0.60315.1
Our software team is creating an ASP.NET web application, and the customer has requested that we use Microsoft Visual Studio 2012 with Microsoft CodedUI to run automated tests.
I ran our ASP.NET application in Google Chrome Version 38.0.2125.111 m
I downloaded and installed the "Selenium components for Coded UI Cross Browser Testing"
Also, I've added the Selenium DLLs to my Microsoft Visual Studio 2012 CodedUI project.
IWebDriver driver = new ChromeDriver(@"D:\blabblahblah\SeleniumConfigFiles\");
driver.Navigate().GoToUrl("http://localhost:2816/");
IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
wait.Until(drv => drv.FindElement(By.LinkText("System")));
var btn = driver.FindElement(By.LinkText("System"));
btn.Click();
Unfortunately, the last line of code always yields the following error:
System.InvalidOperationException was unhandled by user code
HResult=-2146233079
Message=unknown error: Element is not clickable at point (163, 36). Other element would receive the click: <div class="loading-screen">...</div>
(Session info: chrome=38.0.2125.111)
(Driver info: chromedriver=2.8.241075,platform=Windows NT 6.1 SP1 x86)
Source=WebDriver
StackTrace:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 1012
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 846
at OpenQA.Selenium.Remote.RemoteWebDriver.InternalExecute(String driverCommandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebDriver.cs:line 729
at OpenQA.Selenium.Remote.RemoteWebElement.Execute(String commandToExecute, Dictionary`2 parameters) in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebElement.cs:line 810
at OpenQA.Selenium.Remote.RemoteWebElement.Click() in c:\Projects\WebDriver\trunk\dotnet\src\webdriver\Remote\RemoteWebElement.cs:line 336
at JigsawCUITChrome.UIMap.RecordedMethod1() in d:\blahblahUIMap.Designer.cs:line 55
at JigsawCUITChrome.CodedUITest1.CodedUITestMethod1() in d:\blahblah\CodedUITest1.cs:line 31
InnerException:
Could you please tell me how I can resolve the error above?
Upvotes: 1
Views: 5068
Reputation: 291
I was also the same issue while working with chrome driver I have tried couple of scenario which worked for me.
Below are the solution that I tried
It mostly happens in Chrome so if you are mostly working with Firefox or IE then you will not be getting this exception. Chrome does not calculate the exact location of element Chrome always click in the middle of Element. Some time you will get this exception due to Sync issue also.
http://learn-automation.com/how-to-solve-element-is-not-clickable-at-pointxy-in-selenium/
Upvotes: 0
Reputation: 708
Instead of doing a blind wait, you can wait for the blocking element to go away
Selenium has no built in exists property or method, but you can easily make one.
public static bool Exists(IWebDriver driver, By locator)
{
try
{
driver.FindElement(locator);
return true;
}
catch (NoSuchElementException) { return false; }
}
IWebDriver driver = new ChromeDriver(@"D:\blabblahblah\SeleniumConfigFiles\");
driver.Navigate().GoToUrl("http://localhost:2816/");
IWait<IWebDriver> wait = new OpenQA.Selenium.Support.UI.WebDriverWait(driver, TimeSpan.FromSeconds(30.00));
wait.Until(driver1 => ((IJavaScriptExecutor)driver).ExecuteScript("return document.readyState").Equals("complete"));
wait.Until(drv => drv.FindElement(By.LinkText("System")));
wait.Until(drv => ! Exists(drv, By.CssSelector("div.loading-screen"); // Added wait here for the loading element to go away
var btn = driver.FindElement(By.LinkText("System"));
btn.Click();
Upvotes: 2