Git Product home page Git Product logo

Comments (6)

fhoeben avatar fhoeben commented on June 21, 2024

I don't know. Maybe you can check with a debugger what is happening exactly (where this error is being raised in code).
Getting the alert text of course expects the alert to be present.

Maybe some generic handling (which is active before or after the actual alertText method) throws this error? I've had similar issues in the past when I created subclasses where I forgot to take into account alert handling. It could be something from the subclasses of BrowserTest that are being used, or something in BrowserTest itself.

Given that error only occurs sometimes makes it very hard to track down. Without some additional details I'm afraid I won't be able to help you

from hsac-fitnesse-fixtures.

pvbemmelen62 avatar pvbemmelen62 commented on June 21, 2024

I've searched the source code from hsac-fitnesse-fixtures , and found only lines that catch an UnhandledAlertException (in BrowserTest.java and AllFramesDecorator.java), but no lines that throw such an exception .

I have the feeling that the webdriver throws an UnhandledAlertException when it shouldn't. I don't see how generic handling before or after the actual alertText method would be responsible for throwing such an alert; nor do see a reason for such generic handling code to intercept an UnhandledAlertException in case of an alertText method.

On page https://www.w3.org/TR/webdriver2/#user-prompts it says:

When a user prompt appears, it is the task of the subsequent command to handle it. If the subsequent requested command is not one listed in this chapter, an unexpected alert open error will be returned.

image

The command "Get Alert Text" is allowed when an alert is present. So no "unexpected alert open error" should be generated.

What should I do to confirm that the webdriver is the root cause ? Maybe show in the W3C Protocol data that the browser driver generates an "unexpected alert open error" when it shouldn't ?
Webpage https://www.browserstack.com/guide/architecture-of-selenium-webdriver , section Architecture of Selenium 4 WebDriver , shows the W3C Protocol connecting "Selenium Client Libraries" and "Browser Drivers" .
Maybe I can set a breakpoint somewhere in the Selenium Client Library .

from hsac-fitnesse-fixtures.

tcnh avatar tcnh commented on June 21, 2024

Does executing this snippet:

|script|browser test                                        |
|open  |https://the-internet.herokuapp.com/javascript_alerts|
|click |Click for JS Alert                                  |
|show  |alert text                                          |
|confirm alert                                              |
|click |Click for JS Confirm                                |
|show  |alert text                                          |
|confirm alert                                              |
|click |Click for JS Prompt                                 |
|show  |alert text                                          |
|dismiss alert                                              |

Give you the same exception in some cases?

In terms of setting breakpoints, I would start at get alert text and step into the selenium code from there

from hsac-fitnesse-fixtures.

pvbemmelen62 avatar pvbemmelen62 commented on June 21, 2024

I ran the snippet 20 times, and never got the "Unhandled alert" .

from hsac-fitnesse-fixtures.

pvbemmelen62 avatar pvbemmelen62 commented on June 21, 2024

Is it possible to set the log level of the webdriver ?
That might shed some light onto the problem.

https://www.selenium.dev/documentation/webdriver/browsers/edge/
shows java system properties
EdgeDriverService.EDGE_DRIVER_LOG_PROPERTY
and
EdgeDriverService.EDGE_DRIVER_LOG_LEVEL_PROPERTY

I've tried these with command that starts FixtureDebugTest.main . That didn't work. The log file location doesn't get written to.

And I've tried these as value for COMMAND_PATTERN at the top of the test script:

!define COMMAND_PATTERN {java -DEdgeDriverService.EDGE_DRIVER_LOG_PROPERTY=C:\Users\PBEMMELE\paul\tmp\FixtureDebugTest\log.txt -DEdgeDriverService.EDGE_DRIVER_LOG_LEVEL_PROPERTY=ALL -cp %p %m}

Doesn't work either: the log file doesn't get written to.

from hsac-fitnesse-fixtures.

pvbemmelen62 avatar pvbemmelen62 commented on June 21, 2024

From looking at code from https://github.com/SeleniumHQ/seleniumhq.github.io/tree/trunk/examples/java
I found the correct command :
!define COMMAND_PATTERN {java -Dwebdriver.edge.logfile=C:\Users\PBEMMELE\paul\tmp\FixtureDebugTest\log.txt -Dwebdriver.edge.loglevel=all -cp %p %m}

The hope is, that the log file will provide some clue when the Unhandled alert arises.

I'm not sure how to make sense of the contents of the log file; it contains many lines, and I guess I'll have to look up the protocol for DevTools WebSocket .
And use grep to look at specific lines .
For example, for the test snippet suggested by tnch 5 days ago, that opens https://the-internet.herokuapp.com/javascript_alerts , I got the following lines when using some grep command:

pbemmele@V2W1-PBEMMELE /cygdrive/c/git/seleniumhq.github.io-trunk/examples/java/src/test/java $ wc !$ wc "C:\Users\PBEMMELE\paul\tmp\FixtureDebugTest\log.txt" 4417 18069 351047 C:\Users\PBEMMELE\paul\tmp\FixtureDebugTest\log.txt pbemmele@V2W1-PBEMMELE /cygdrive/c/git/seleniumhq.github.io-trunk/examples/java/src/test/java $ grep -A1 -B1 "using" "C:\Users\PBEMMELE\paul\tmp\FixtureDebugTest\log.txt" [1713717717.236][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "link text", "value": "Click for JS Alert" -- [1713717717.264][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//a[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Alert']]" -- [1713717717.287][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//button[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Alert']]" -- [1713717717.569][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "link text", "value": "Click for JS Confirm" -- [1713717717.594][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//a[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Confirm']]" -- [1713717717.612][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//button[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Confirm']]" -- [1713717717.766][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "link text", "value": "Click for JS Prompt" -- [1713717717.792][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//a[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Prompt']]" -- [1713717717.817][INFO]: [d9400923de8854e97989896069bb2098] COMMAND FindElements { "using": "xpath", "value": ".//button[descendant-or-self::text()[normalize-space(translate(., ' ', ' '))='Click for JS Prompt']]" pbemmele@V2W1-PBEMMELE /cygdrive/c/git/seleniumhq.github.io-trunk/examples/java/src/test/java

from hsac-fitnesse-fixtures.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.