C# Selenium WebDriver Hangs on same page - selenium

No matter if I do a FindElement. Or on the Wait.Until.
var wait = new WebDriverWait(Driver.Instance, TimeSpan.FromSeconds(10));
wait.Until(d => d.Title == pageTitle);
I get the following error:
OpenQA.Selenium.Remote.RemoteWebdriver.Title.Get timed out and needed to be apborted in an unsafe way. This may have corrupted the target process.
It says one way to fix it is to click on the 'enable property evaluation and other implicit function calls'...but that doesn't help. Just hangs and gives me a less detailed message. What could cause the hangup on Just trying to get the Title of a page? I need help to look in a new/correct direction, so far I have been hitting dead ends.
Chrome -- Version 76.0.3809.100
Selenium.WebDriver.ChromeDriver version 76.03770.....going to upgrade this one...to be closer

Giving Credit where Credit is due....I thought I had these synced up..... I did not..from one greg to another...thank you.
Usually these things are the result of a mismatch between the web driver version and the version of the browser you are interacting with. – Greg Burghardt

Related

Cannot determine loading status in Google Maps

I had a test written in Java and Selenium that basically does a search for a provider. It then clicks on the provider's Map This Location link and opens a google map. I would wait for an xpath visibility for that map after switching to the new window.
The URL would be something like
https://www.google.com/maps/dir//945+N+12th+St,+Milwaukee,+WI+53233/#43.0426642,-87.9297109,17z/data=!4m8!4m7!1m0!1m5!1m1!1s0x88051979232b79cd:0x905e19b746c46eb3!2m2!1d-87.9275222!2d43.0426642
This has been working fine for a year. Today we got updated to Chrome version Version 74.0.3729.108 (Official Build) (64-bit) so we replaced our old Chromedriver (which was now giving us an error that the Chrome version had to be between 70 and 73) with 74.0.3729.6 which our head developer downloaded from the site.
The problem is, now, and only for certain addresses, I get that error
unknown error: cannot determine loading status from no such execution context
Some Stack Overflow items suggested
1. Updating the Chrome Driver
2. Using a longer timeout
as you can see from above we updated our chromedriver to be consistent with the version of Chrome. I also updated the timeout to 300 seconds (5 minutes), but all in vain.
I am out of ideas about what else could be causing the problem. The xpath I waited for was //div[#aria-label='Map'] but I have tried other xpaths now too, such as "//div[#id='streetviewcard']". I verified that the window I switched to was driver.getWindowHandles().get(1). I had saved the original handle so I could switch back. I looked at all the window handles, and there were only 2, the original one and the one I switched to.
No other searches come up with anything useful.
I had exactly the same error, moving to v74.
Something must have changed with chromedriver, or chrome - I assume that when a new tab is opened, execution continues sooner than it did before. It's hard to tell what's actually changed, but ultimately I fixed our issues with a sleep:
Also, it's worth noting that getWindowHandles() returns in an undefined order - so might need some extra handling depending on your use case.
https://github.com/dvsa/mot-automated-testsuite/compare/ops-OPSTEAM-2827-selenium#diff-1fa0893dd1ad67d9c1a4ee1e777c20cb

Conditional wait vs implicitlyWait -Selenium

please help me in understanding the following issue. please.
I have to get all links and check them later. I used the following code:
open(url);
List<String> links = new ArrayList<>();
for (SelenideElement link : $$("a"))
links.add(link.attr("href"));
when I used this with Linux with these api version:
Maven 3.1
Selenide v3.5
Selenium v2.53
Firefox v45.0.1
Then code can't take time enough to catch links from the page. Then I have to add driver wait before get links.
I Add the following (which is conditional wait):
WebDriverWait waitLog = new WebDriverWait(WebDriverRunner.getWebDriver(), 20);
waitLog.until(ExpectedConditions.visibilityOf($(By.tagName(Selector))));
And it worked fine and I run it more than one time.
I got surprised when running it yesterday, it didn't work and can't get time enough to get links!
So I replace the conditional wait with implicit wait, and add the following:
WebDriverRunner.getWebDriver().manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
Now it is working fine.
What happened?
What is this thing make it work sometimes and sometimes can't work?
How to return back to the conditional wait with keeping the code working well?
So how to recover this problem? and prevent this problem from happens in the future.
There might be some delay in loading the url for the second time. Please try increasing the delay time for conditional wait. The main difference between explicit and implicit wait is as follows.
Explicit or conditional wait stops the WebDriver for the specified amount of time, till the mentioned element is available. Whereas implicit wait will skip execution of WebDriver for specified amount of time, for every element which is not found on the page.
Hope this helps.

How to `executeScript` before page load by WebDriver in selenium?

I want to use webdriver in nodejs to control a website which use ajax very heavy, especially it always have http request to server.
When I use driver.executeScript , I found the promise returned almost never resovled.
I checked the website, found that it use a keep-alive http request loop to communicate with server. That means, it will always have at least one live connection to server for 30s, then another connection for another 30s, again and again. which cause document.readyState keep interactive instead of completed, and then driver.executeScript almost be blocked forever.
I had tried driver.manage().timeouts().pageLoadTimeout(PAGE_LOAD_TIMEOUT_MS) but it only throws a exception after timeout.
I also tried to stop the connections by press ESC on the browser window. after that, it seems driver.executeScript can run immediately. But I didn't find any function like window.stop() in WebDriver API.
so is there have a way to resolve this problem? Either should be ok like:
run executeScript right now, regardless of whether page is loaded;
a webdriver api like driver.browser.stop() could stop all live connections in page.
Nodejs code to re-produce this problem:
const WebDriver = require('selenium-webdriver')
const driver = new WebDriver.Builder()
.withCapabilities(
WebDriver.Capabilities.firefox()
.set('webdriver.load.strategy', 'unstable')
).build()
driver.get('https://wx.qq.com/')
driver.executeScript('return "99% will be blocked, 1% luck to return"')
.then(function (ret) {console.log(ret)})
thanks!
UPDATE:
I found maybe set webdriver.load.strategy to unstable in firefox will be help.
FirefoxProfile fp = new FirefoxProfile();
fp.setPreference("webdriver.load.strategy", "unstable"); WebDriver
driver = new FirefoxDriver(fp);
https://github.com/seleniumhq/selenium-google-code-issue-archive/issues/4993
https://w3c.github.io/webdriver/webdriver-spec.html#page-load-strategies-1
Links from others got same problem:
http://grokbase.com/t/gg/webdriver/1263dbyws6/how-to-click-stop-button-or-equivalent
I think that if you don't use Implicit time the driver won't wait till it's loaded so you'll be able to execute your script.
If this don't work you can try to use your own timer. Check if doc state is ready, if it's not ready after some timeout then stop it manually (by JS) and run your script.
By using Thread.sleep(secs);. For example, we want to load a page in 3 secs means we write thread.sleep(30000);.

Getting web driver logging information running Protractor

So I am in the process of writing some tests with Protractor for an angular application I am working on. I ran into an issue where a test was failing because I tried to click on an element that while existed, it could not be clicked because another element was above it and it was receiving the click event. The error was just that true not does equal false which gives no insight to the real underlaying issue. I have run into this issue many times with other tests so I knew pretty quickly was the issue was but if I had not experienced this before, I don't know how long it would take me to figure it out.
I am 99% sure that when you send a click event with the JSON Wire Protocol that if the element does receive the click, there will be a message relating to that in it's response. Is there any way with Protractor to get the JSON Wire Protocol responses on to the screen when running the tests or at least get the responses captured in a file or something?
Assuming you are using Jasmine (the default) i suggest you start using explicit waits for elements to be present and visible before interacting with them like in your example.
I'm using this custom mathers.
Then:
var theElementFinder = $('#someElm');
expect(theElementFinder).toBePresentAndDisplayed();
Regarding
a way with Protractor to get the JSON Wire Protocol responses
You already see selenium errors in your Terminal / Console output.

Selenium RC - t.replace is not a function

[edit for godman] I am working on a web based application, written in PHP. I am using Selenium RC to run tests on the webpages produced by this application, through a browser.
I just upgraded to Firefox 14, so I had to upgrade to Selenium RC 2.25.0.
Now I'm seeing this error when running a test with htmlSuite:
Command execution failure. Please search the user group at
https://groups.google.com/forum/#!forum/selenium-users for error
details from the log window. The error message is: t.replace is not a
function
The command executed is:
clickAndWait //a[text()='! selenium test customer']
As you can see, it's not doing anything too tricky - just clicking a link. The test runs fine in the IDE, it's just when run via RC that it's a problem.
Searching in the groups revealed only really old threads dating back to version 1 of selenium.
Any ideas anyone?
[edit] I've been running the test that has these problems several times a day for the last week - and it doesn't seem to fail like this every time. This looks like it's a random problem. Has anyone seen this happen before?
[edit after the bounty got me no answers] Another example of it failing is with:
clickAndWait css=a.edit_company
This same call works fine earlier in the same test, on the same page.
[edit] Now I'm seeing the same error with a completely separate command:
type id=Address1 Address1
Does anyone have any suggestions about this? Any way I can even debug what's going on (I don't see this in the IDE at all)
I am not terribly familiar with clickAndWait. I personally prefer clicking and then doing my own custom waiting.
Try just clicking and add a Thread.Sleep(5000), or something similar, and see if the error is a result of the click or the wait part.
If it is the wait part, then I have a different suggestion than if it is the click part.
I've seen similar issues across various platforms. It has always been somewhat random for me, so I don't use clickandWait. Generally is is much more reliable to do a plain click, and then wait for specific condition. You could do a waitforpageload, but that has also been unreliable for me so I prefer things like waitfortextpresent and waitforelementpresent.
Usually, this kind of error would occur if you are dealing with something that is not a string. Could you just make sure that you are dealing with strings only?
2 possibilities where it is arising from:-
When text() is executed -> it might be dealing with a non-string
a[expression] -> the expression(text() = '! selenium test customer') when evaluated to False/True might be the problem because if a is a Map/array, the corresponding key should be a string and not a bool, probably.
text()='! selenium test customer' -->> is it an assignment operation? if yes, make sure that text() returns a lvalue or a mutable object (based on the language you are using selenium rc with)