-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
org.getopentest.selenium.HandleModal doesn't work #604
Comments
I'm not surprised you're seeing problems with this, as modals handling is notoriously tricky in web testing. This topic doesn't receive much attention anymore, since basic authentication is a bad practice and not used in modern applications. The causes for the error could be either the Selenium Java client library or the WebDriver executable for the browser you are testing with. The most likely culprit is the WebDriver - please check that you are using the right WebDriver executable for your browser version. The way OpenTest uses Selenium is pretty straightforward and it is unlikely to be the cause of the error. You can take a look for yourself here. If you notice any problem, I'd be happy to help with providing a fix, but the code is very simple and unlikely to be the cause of the issue you're seeing. One other thing people suggest is to try and avoid the modal dialog altogether by providing the authentication details in the URL. See here for more information, if this is a viable option for you. |
Hi @adrianth , This is not HTTP Authentication modal, but a simple alert box. I tried the same site with pure Selenium and it works fine:
The problem is definitely in OpenTest. The alert box is closed before the
Did you run the test by yourself? |
If the code that you included above works fine, then the Selenium Java client library used in OpenTest is the source of the problem. Can you please let me know what version of the Selenium Java client library you used for your test? |
I am using Selenium API version 3.14.0 |
OpenTest is using 3.141.59. I was pretty sure you were using version 4. Now I am really confused as to what the root cause may be. :-( |
Hi any advance on this, I am with the same problem |
I also came across the fact that HandleModal does not work. In my situation, just replace with http://user:pass@url it is impossible due to the peculiarities of the site, so processing the browser request is the only solution (from what I know) UPD: The problem in my case was that when authenticating in this way (http://user:pass@url ) the page did not load. But I found out that if I then go to the same link without authentication (http://url ), then the page will load completely, moreover, you will be under the user entered earlier. Config: description: Open my url
actors:
- actor: WEB
segments:
- segment: 1
actions:
- description: auth on my site
action: org.getopentest.selenium.NavigateTo
args:
url: http://user:password@mysite.test/
- description: Navigate to my site homepage
action: org.getopentest.selenium.NavigateTo
args:
url: http://mysite.test/ |
OK, I found one crutch, but it works. - description: Auto click "OK" for allert
action: org.getopentest.selenium.ExecuteScript
args:
script: |
window.confirm = function() {return true}
- description: Click - Save
macro: ClickSaveButton #Showing allert window UPDI have updated the macro for pressing the save button so that the optional description: Click save button
actions:
- description: Other - Check whether the autoclicker needs to be set up
script: |
$localData.isNeedSetupHandlerClicker = false
if(typeof($macroArgs.confirmAllert) === 'boolean')
$localData.isNeedSetupHandlerClicker = true
- description: Other - Build the browser script to set allert auto answer
action: org.getopentest.actions.Format
args:
template: |
window.confirm = function() {return ${$macroArgs.confirmAllert}}
$if: $localData.isNeedSetupHandlerClicker
- description: Other - Set allert auto answer
action: org.getopentest.selenium.ExecuteScript
args:
script: $output.text
$if: $localData.isNeedSetupHandlerClicker
- description: Click - Save
action: org.getopentest.selenium.Click
args:
locator: { xpath: "//input[@value='Save']" } Inside test:
- description: Click - Save
macro: ClickSaveButton
# args:
# confirmAllert: true
# confirmAllert: false |
Action
getText
seems to close the Alert Box without reading the text and then it throws:java.lang.RuntimeException: org.openqa.selenium.TimeoutException: Expected condition failed: waiting for alert to be present (tried for 10 second(s) with 500 milliseconds interval)
Action
accept
does the same - the alert box is closed and then the same exception thrown.The text was updated successfully, but these errors were encountered: