3

I am struggling with this stale-element-exception. Now I had the idea that I could perhaps maximize the logging in order to get a closer look on what's actually happening. I am instantiating the ChromeDriver by using the syntax in which I pass an instance of ChromeDriverService (for which I had set LogPath to a file and EnableVerboseLogging as true.)

However, this "verbose" logging is not really helpful:

[1591200174.654][INFO]: Starting ChromeDriver *.*.*.* (ccbf011cb2d2b19b506d844400483861342c20cd-refs/branch-heads/4103@{#416}) on port 57550 
[1591200174.654][INFO]: Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. 
[1591200174.659][SEVERE]: bind() returned an error: Normalerweise darf jede Socketadresse (Protokoll, Netzwerkadresse oder Anschluss) nur jeweils einmal verwendet werden. (0x2740) 
[1591200174.659][INFO]: listen on IPv6 failed with error ERR_ADDRESS_IN_USE

...and despite the SEVERE-msg (which might indicate "error" to sensitive or unexperienced readers) my tests were actually executed fine. But given that I ran >20 tests, this log is useless. What I would really like to see is a log about the things that happen in the browser: i.e. when calling ChromeDriver.MoveToElement etc.

Is there a possibility to get such detailed logs - and what do I need to do?

UPDATE: what exactly do I want to log? Well, I'm actually struggling with two things:

  1. "stale element": my code is not changing the page. And basically I do elem=FindElementByCSSSelector and then MoveTo().Build.Perform. I don't get how an element can become stale between those steps - so I suppose I need some insight into what's happening inside WebDriver/ChromeDriver.

    2.if I run the same code under MacOS or Linux, it fails when instantiating ChromeDriver. I already found various security issues which I resolved - but now I'm getting "Connection refused" (which I guess relates to the communication between WebDriver/ChromeDriver and the browser - and Google-searches did not help). So I'd like to see some logging of those processes.

Disclaimer: I'm not asking this on Stackoverflow because SO is about problems with actual code - and this question is more about composing that code!

9
  • You will get stack trace by default , so what is your question you want to not log the server error messages from chrome driver ? – PDHide Jun 3 '20 at 19:08
  • Sorry for being a bit vague - I tried to add more info about what I'm looking for... – MBaas Jun 4 '20 at 6:54
  • Can you check if when you are doing the same manually the dom is getting changed? You can watch the dev tools. They highlight the changing parts of the structure. – Alexey R. Jun 4 '20 at 15:17
  • 1
    BTW, Alex - you picked a really nice domain there! I like that a lot :) – MBaas Jun 5 '20 at 8:10
  • 1
    I think you need to implement this problematic part using some other client libs. Probably using Java or python so that you exclude possible C# bindings issues. – Alexey R. Jun 5 '20 at 13:54
1

That depends on what exactly you want to log. The webdriver has a getLog method which will (on chrome at least) give out everything logged to the Javascript console. By injecting js using the JavascriptExecutor you can access the window.performance object to log a network trace. The same works for local and session storage as well as set cookies to get a better introspective of the internal state of your application when an error is encountered. For network logging running a Wireshark on your nodes machine is even better since you can get full har files from there. If you want to log behavior in your testscript (for example faulty selectors) this will not show up so you'll need logging there too. For network logging of communication within the selenium grid you can pipe the hubs and nodes output into a logfile by just adding " > {pathToFile} " behind your call to the servers jar file.

Since you didn't mention the language you're using I can't provide implementation details but I'd be happy to supply them if you have need for some.

1
  • Thanks - I have added more details... – MBaas Jun 4 '20 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.