How do I negotiate alert boxes in Watir? - ruby

I am trying to create an automation script for a website using Ruby with
Watir.
I ran into a situation where I have to choose 'Yes' or 'No' in an
alert box. The problem is that I am not able to identify the alert box
as a component of the page so that I can obtain its identifier and use
it to select an option.
I found some information how to
create an alert box, but I need to navigate through one. Can
anyone help me out?

It sounds like you have a confirm box if you can choose two options ("OK" or "Cancel"). If you want to simulate clicking "OK", you have to put something like this before you trigger the confirm.
# return true for confirm to simulate clicking OK
b.execute_script("window.confirm = function() {return true}")
If you just have an alert with a single "OK" button, do this.
# don't return anything for alert
b.execute_script("window.alert = function() {}")
See this page for more examples.

The approach suggested by Austin Taylor may work fine, but I think that for a more general solution you need to deal with Popups at a OS level as Chuck suggests.
If anyone reaches this page seeking this sort of answer there are different solutions listed here: http://wiki.openqa.org/display/WTR/JavaScript+Pop+Ups

You can use these clean watir calls:
browser.alert.ok
browser.alert.close
See Official Framework Documentation for more info.

Related

Apple script to click link button at specified time

Could you please give me an example script that allow me to click automatically the link button in the google chrome at the specified time. Thank you so much!
I thought I can modify this: https://apple.stackexchange.com/questions/81062/applescript-click-automation-in-google-chrome-browser
But I am not sure how to do this.

Google Picker - Alert - You are about to send 1 item to localhost. Would you like to continue?

I'm using Google Picker Api. Google Picker is showing properly but when I select a file (selecting a file and clicking the Select button or double clicking a file), I get this alert: An embedded page at docs.google.com says You are about to send 1 item to localhost. Would you like to continue?
I'm using Nuxt/Vue but I'm not sure it relates to that. As shown in the image, the Alert is really coming from the Picker API itself. I tried googling this specific Alert but I can't find anything with the same problem.
When I confirm the alert, it works, but I'm not sure if this alert is intended or not. If it is, then I think I need to leave it as it is. If it's not, please let me know how to get rid of it.
As pointed out by #Aerials:
Check this issue tracker and give it a star if you're having the same/related problem.
Here's another one. A possible duplicate.
This issue has been reported in Google's Issue Tracker here:
https://issuetracker.google.com/184573419
Add a "+1" next to the issue number to indicate you are affected by it too.

mouse over and click in Capybara

Got stuck in capybara coding. appreciate any help on this.
I need to mouseover on source element to click on the target element link.
Not finding a way to get it. need to use this in chrome browser only.
Tried the code below
source=ses.find('#source-link')
ses.driver.action.move_to(source).perform
ses.find('#child-link').click
If what you're trying to do is hover over #source-link and then click `#child-link' it should just be
sess.find('#source-link').hover
sess.find('#child-link').click
If that doesn't work for you then we need to know exactly what events are triggering the behavior you expect.

Google Chrome Frame - custom install dialog with "onmissing"

Can anyone point me at an example of a customized Google Chrome Frame install dialog?
It looks like GCF allows you to hide the default dialog as a parameter to CFInstall.check() (onmissing, preventPrompt) but I haven't been able to find an example of what the expected structure of onmissing is.
I can have onmissing launch a custom dialog of my own, with jQuery or similar, but don't know exactly where to link to in order to start the install process correctly. Whenever I redirect to the installer directly, I get prompted for an admin password, unlike when I use the default GCF install dialog.
Thanks!
this article helped me . Check it out.

Firefox Extension - Monitor refresh and change of tab

I need to know when a user refreshs the page and when he switches to another tab.
Does anyone has a clue how to capture this in a firefox extension?
Best regards
Christian
What you seem to want is knowing when the value in the location bar changes. This requires implementing nsIWebProgressListener interface. The only method you really need is onLocationChange, rest of them should be dummies. You can find the documentation along with code examples here: https://developer.mozilla.org/en/Code_snippets/Progress_Listeners. You can also use progress listeners to monitor page loads.

Resources