Testcafe native browser dialog not displaying, getNativeDialogHistory is undefined - javascript

I'm just getting started with testcafe. The website that I need to test has a native browser window alert that loads before anything displays on the page, and that alert prompts the user for credentials. If the cancel button is clicked, the page is blank except for one word "unauthorized".
When I have my test navigate to the website, I see no window alert at all. The page immediately displays the "unauthorized" message. Is testcafe automatically closing this alert? Neither setNativeDialogHandler nor getNativeDialogHistory are working. How can I have testcafe enter text into two fields in this dialog?
Thank you!

I suppose your site has HTTP authentication. TestCafe can work with HTTP authentication, however, it prevents showing the dialog. This means that everything will work, but you will not see the dialog.
Please read the following
article: https://devexpress.github.io/testcafe/documentation/test-api/authentication/http-authentication.html

Related

How to display “allow dialogs from … to take you to their tab” in an alert?

I was in a website where an error message appeared in an alert dozens of times, saying only:
error :(
I’m used to websites automatically displaying a checkbox labeled “prevent this page from creating additional dialogs” after many error messages. This should have happened to the above site, but it didn’t. Instead it displayed a checkbox “allow dialogs from [example.com] to take you to their tab?”
Do you know why this happened? How do I reproduce this behavior in my own website?
PS: My browser is Firefox 72.0.2.
EDIT
4 months... Nobody have ever seen such a message?
This shows up in Firefox when a page that is not in view (some browser tab that is not activated) tries to display an alert() dialog. You might get this when some code that runs in background creates an alert message: like when you press a button, and some code runs in the background and you switch to another tab, and now the old tab finishes running and displays alert dialog.

How to change the text on the page refresh message pop-up?

I have a web page that gets refreshed, when something happens on any of its children pages. When it happens, the IE pop-up appears with the following message: "To display the webpage again, the web browser needs to resend the information you've previously submitted. If you were making a purchase, you should click Cancel to avoid a duplicate transaction. Otherwise, click Retry to display". See the image attached:
I'm ok with all that, but I was wondering if there's a way to change the actual text of the message, for example, removing the last sentence. I know this pop-up can't be tampered with, but perhaps there's a way to replace it with a custom made pop-up, serving the same function, but showing a different text. I assume first I would have to suppress the original message, then call a confirm box in a beforeupdate function, where clicking OK (for example) would resend the information submitted and Cancel would let you remain on the page without refreshing it. However, my Javascript and JQuery knowledge is a bit rusty and I'm not sure how to implement it properly. Any help is appreciated.
Thank you

How to storeConfirmation in popup SeleniumIDE

Can u help me about StoreConfirmation for popup SeleniumIde ? + example command.
please answer only selenium IDE.
Thanks
If you are talking about default javascript alert or confirmation there are two commands for it:
storeAlert
Returns:
The message of the most recent JavaScript alert
Retrieves the message of a JavaScript alert generated during the
previous action, or fail if there were no alerts.
Getting an alert has the same effect as manually clicking OK. If an
alert is generated but you do not consume it with getAlert, the next
Selenium action will fail.
Under Selenium, JavaScript alerts will NOT pop up a visible alert
dialog.
Selenium does NOT support JavaScript alerts that are generated in a
page's onload() event handler. In this case a visible dialog WILL be
generated and Selenium will hang until someone manually clicks OK.
storeConfirmation
Returns:
the message of the most recent JavaScript confirmation dialog
Retrieves the message of a JavaScript confirmation dialog generated
during the previous action.
By default, the confirm function will return true, having the same
effect as manually clicking OK. This can be changed by prior execution
of the chooseCancelOnNextConfirmation command.
If an confirmation is generated but you do not consume it with
getConfirmation, the next Selenium action will fail.
NOTE: under Selenium, JavaScript confirmations will NOT pop up a
visible dialog.
NOTE: Selenium does NOT support JavaScript confirmations that are
generated in a page's onload() event handler. In this case a visible
dialog WILL be generated and Selenium will hang until you manually
click OK.
You can see working example here : http://www.software-testing-tutorials-automation.com/2013/10/selenium-ide-what-is-use-of.html
Hope it will help you.

Scripts not running in FF and Chrome

I am using javascript alert message to show validation messages. In Firefox and Chrome first time working fine,second time for same alert same its asking message like "Prevent this page from creating additional dialogs" with check box. After select that check box, Next time button click scripts not executing. How to block that message?
Use a JavaScript Modal popup! eg. JQuery UI Modal Popup
This is a browser matter, so you as a developer cant do anything with that behavior.
Here is a similar question
already answered here
unfortunately you can't be sure that user has his browser settings with javascript alerts popup on ( that called with 'alert('...') function').
You should use javascript dialog plygin instead.
For example:
http://fancybox.net/
its a browser property for the client,if he doesnt want to view these alerts. you cant remove that check box and message.
if this message is shown then what the problem, leave it for the user.
why you want to force him to view these alerts,
it must be user's wish to see or not see these alerts.
for better user experience and for your purpose you can use fancybox or facebox
fancy box fiddler check this http://jsfiddle.net/BJNYr/

JavaScript problem toolbar=no

I have a simple logon page. When the user is validated, the window navigates to a new page. The javascript is window.open('http://www.google.com',"mytest",'toolbar=no'); My expectation is that when it navigates away from our logon page and opens the google site that the back button would be disabled. But it's not. Does anyone have any idea why?
It depends on your browser. Ultimately, all you can do with javascript's window.open() is tell the browser what you'd like it to do, but it's not obligated to do it. Browsers can and do ignore some directives based on user preferences.
I believe the option your looking for is 'location=no', as that hides the address bar and therefore the back button too. The toolbar is things like favorites/etc.
This is bad practice - what happens if the user has javascript disabled? If the browser prevents the js from removing the toolbar of the main window?
Instead, amend the logon page to detect whether the user is logged in before showing the login form. If logged in, show a message saying so instead of the form - that way, a user clicking back won't be a problem.
I find it very annoying when a website messes around with my browser window, and generally don't come back.
This is what worked for me. Instead of disabling the back key. I listen for on unload event. I then write the following in javascript:
window.onbeforeunload = function () { return "You should not press the back button while in this application. If you continue, your work will not be saved and you will need to log back in."}
Java Script pops a dialogue box with OK and Cancel options. If the user clicks cancel. The application stays right where they are. The script is embedded within the tags. For me this is the ideal solution. I found this at
http://www.hunlock.com/blogs/Mastering_The_Back_Button_With_Javascript

Categories