I am using Selenium Web Driver and encountered following exception while trying to click a proper element in web browser: Unable to locate element.
XPaths are 100% correct.
The strange thing is it is working ok when:
In debug mode.
After clicking Continue in VS when exception appears.
When i am moving mouse manually on the screen.
I would be grateful for any help.
EDIT: Thread.Sleep doesnt help. I am trying to click decrease Year button in web calendar. It works first time, but freezes the second time. But the object is still there. So i dont understand how it can be not visible.
The driver is trying to locate the element before it loaded. Try waiting for it before clicking.
wait.Until(ExpectedConditions.ElementIsVisible(By.XPath(path))).Click();
There are a few things you can try:
1-try a selector by ID instead of the xpath. Maybe new elements are being rendered and making the xpath didn't find the element.
2-implement a retry pattern
3-use thread sleep to let the page being full rendered.
Related
So this is similar to Click() method will not always work but there are several vital differences:
Not a timing issue because I repeatedly try to click it until success
No exception is thrown, just nothing happens
Using a JS click on the same element works - executor.executeScript("arguments[0].click();", element);
Using button.SendKeys(Keys.Return) instead works.
Displayed: true and Enabled: true
Only button.Click() doesn't work. I've stopped the application at a breakpoint and am testing it via the Immediate Window right now. I can see how Click() has no effect and doesn't throw an exception, but javascript click() and SendKeys() work.
Some additional info:
I'm using InternetExplorerDriver on IE11
I'm running the tests on Windows Server 2012 through Remote Desktop
It happens only intermittently. I remember switching Alt+Tab while the tests are running whenever it's happened but I don't know if this is the reason.
Any idea what is happening?
Edit: I noticed at one point that the first click pushes down the button (visibly) but it doesn't get click. The second click succeeds, however. Earlier Click() did not succeed, no matter how many times I executed it.
Edit 2: OK, now I've nailed it - if I click on the browser window, then I click to Visual Studio, then the first Click() doesn't work. Subsequent clicks all work, even if VS is still focused. Switching from VS to notepad and then to VS does not trigger it, only switching to IE and then back to VS.
It's as if it's not the problem that IE doesn't have focus, it's about having it and then losing it, then the next Click() will fail.
In my case the contol was partially overlapped with another div, and the webDriver clicked in the middle of control but hitted the div. Could you please check maybe it is your case.
Google chrome automatically updated to Version 78.0.3904.87 yesterday and i now seem to have a problem with Selenium Webdriver.
When i run my tests in Visual Studio, the click events seem to occur but the expected result on screen does not happen e.g. clicking a link passes through the code (link.Click) successfully with no failure but the link does not get clicked on screen.
When i run the same test in Debug mode and Step Into each section of code it works fine, its as if selenium is running too fast for the browser (i have an implicit wait built in but its irrelevant, the element is there its just not clicking properly). I'm also finding things like sendKeys does not populate the field though it passes through the code successfully, again fine when stepping into it in Debug mode.
I've tried updating my Chromedriver to the version for V78 but this has made no difference
Similar problem here but my issue is not restricted to pdfs only
Chromedriver 78 cant find element in pdf
My team is running into the same issue. The issue seems to be the time between our WebDriverWaits and our Clicks -- the waits seem to be passing through instantaneously in cases they should not and then any Click element call (or action) hovers over what we want to click on but doesn't actually click.
I finally got to the bottom of this with our setup and it turned out to be the --enable-automation flag that seemed to be causing page flickering on page load.
After adding excludeSwitches: ['enable-automation'] to my config it has resolved the issue.
I'm having a bit difficulties with Chrome driver and Selenium, I have selenium.support version 3.141.0, chrome driver version 2.43.0 and Google Chrome version 71.0.3578.98.
During a test run I click on a button which opens a new window, but for some reason the window is blank instead of the site that should have been loaded. I tried to reproduced it manually but it doesn't happen except from test run.
Do you have any explanation or know the reason for this occurrence?
I have had this issue a few times...
What I have found was that the element that I'm trying to click is not the element that actually invokes the rerender to next page...
My solution
So... to get to the parent element I have used the parent method in XPath.
for example, if I am looking for an element with id='x_d' so I use: Window.WaitForElement(By.XPath("//*[contains(#id, 'x')]")).click();
Now the problem is that the Invoker is the parent so to access the parent a I'll use:
Window.WaitForElement(By.XPath("//*[contains(#id, 'x')]//parent :: a")).click();
Hope this helps you!
So I have some tests in Selenium using the InternetExplorerDriver implementation of IWebDriver. Many of my objects respond to IWebElement.Click() well and consistently. I have anchors that click reliably for instance. I am writing some new stuff for clicking on a td. That is the element where the event handler is called says Mr Developer of the application under test.
The thing is it SEEMS to only fire click event and present the resultant hidden div when I am debugging the code but not when simply running it. There is not error thrown when the click is attempted.
I know that this is not a timing issue because there is something slow that is happening right before this test which allows the page to fully load.
Any other thoughts? Thanks.
Sorry folks for wasting your time. Operator error.
I'm developing an addon for IE8+.
Main function:
- when I click the toolbar, it will display a box inside every single page, ex: google.com, bing.com, codeproject.com... by using execScript to execute jQuery.
Therefore, what Im doing is run javascript in the current page.
Everything has done except when that page perform an Pop-up, it doesnt work anymore.
I click the toolbar, nothing happen, but when I look at the pop-up, surprise! has the box which im trying to display. So, I think the current tab and the popup of its is running the same process.
I have change registry key TabProcGrowth to 20, to make sure every single tab run by its own process, but maybe it not work with popup.
sr for my bad english, any suggestion is welcome.
Thanks in advance.
update:
I have changed the way to develop my addon, so I change my question, too. (But any suggestion for the 1st question still very useful for me).
My new question still mention the "execScript" problem.
HOW to execute javascript with every individual tab of IE browser with TabProcGrowth = 0. I need this value set to 0 because I have the timer to request to the server every interval1 (ex: 60s). So if there are more than one processes of IE, the addon will send multi request to server at the sametime.
In my situation now, I set TabProcGrowth to 0. Open IE, open some tabs. Click the toolbar at the newest tab, it works, ofcourse!. But when I click toolbar at the old one, nothing happen. The script still be execute but it takes effect on the newest tab.
It's the big problem for me, resolve this problem, you guys save my life.