handling popups with selenium using javascript - javascript

my goal is to enter a username and password into the popup box that appears whenever the page loads. I am using selenium for this task and so far everything that I have tried does not work
I tried using this but it still does not open browser.get("http://username:password#websitecom");
this is my first time working with selenium!
picture of the popup

Try this Website as a reference to solve your problem:
https://www.guru99.com/execute-javascript-selenium-webdriver.html

Related

How to keep a hover effect by selecting a browser suggestion?

I have a WordPress + WooCommerce website and by hovering Login / Sign Up on the header it leads to open a dropdown box where you can enter login details or register. The kind of issue described below also occurs on official theme demo website, at https://xstore.8theme.com/
Now, if I click on "Username or email address" field, Google Chrome shows me an account suggestion based on previously saved accounts on this website. You could try by attempting to login with whatever credentials and if you save them on Chrome (even if wrong), the browser will suggest them to you from the next login attempt. If you just hover the suggestion, all the dropdown box disappears. I said, "just hover the suggestion", because actually you do not have time to click on it.
I suppose this is due to hover effect, in fact if you move the cursor out of the dropdown box, this last disappears, and so happens with the suggestion making it like it was out of the dropdown box.
You can watch a video of the issue at:
https://s.nimbusweb.me/share/3721505/q5vwlz9bho2yufufoiic
How could I solve that?
Thank you in advance,
Alberto
I've had this Problem many times with outdated versions of chrome.
Have you tried updating your browser?
Do you have the same issue in other browsers?
Running updated chrome, I have not experienced this issue on the Demo Page (https://xstore.8theme.com/)

Testcafe native browser dialog not displaying, getNativeDialogHistory is undefined

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

Changes in code not taking effect - Visual web developer

I have a button which is calling a function that displays an alert. The alert is displayed but if I change the messege that the alert is showing, when I press the button the alert will still show the first message I wrote and not the updated one.
It is also happening when I add html tags, they won't show when I run the code.
Why is this happening?
You know the drill: make some edits to your document, click save, switch over to your browser, refresh it, and then observe the changes.
However, every now and again I will catch myself viewing the wrong site page, viewing the site on a different browser, or viewing the client's old live site! Check your address bar + go into your folder and open the page again.

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/

How to not wait for something with Watir-Webdriver

So I'm writing a watir-webdriver script, and my app is using javascript to present a modal window that I want to interact with. When I click the element that presents the modal window, watir-webdriver just sits there until eventually it times out and i see a Timeout::Error on the console window. This is before attempting to interact with the new window at all. I'm assuming it's polling the DOM for some change and not getting it, how do I tell it to move on without waiting?
The answer ended up being, and then handling the necessary waiting manually
element.focus
element.send_keys :return
Ruby 1.9.3/ IE 9 - I had a click_no_wait error. Watir would not trigger a click on the Save button, which had to be followed by a click on a java popup 'OK' button that confirmed that the save button had saved the document correctly.
Using these two lines in place of the click_no_wait command gets the code working perfectly:
element.focus
element.send_keys :return
Thanks DVG. My code -
ie.button(:id, 'MainContent_B_Save').focus
ie.button(:id, 'MainContent_B_Save').send_keys :return
ie. javascript_dialog.button('OK').click
If this is a Alert, Confirm, or Alert type JS popup, see this answer: https://stackoverflow.com/a/8172888/409820

Categories