I have just spent hours stuck on Selenium with Safari before figuring out that I needed to disable popup blocker to allow a login popup that I have.
My question is, is there a way to disable the popup blocker when creating a node/webdriver with Selenium Grid 2, or when creating a RemoteWebDriver in code, or both?
Otherwise, I have to manually remember to change this setting by opening the browser myself. The aim is to have Selenium running across several machines so it would be great to be able to set this programatically.
Ok, here's the AppleScript that I ended up writing:
tell application "System Events" to tell process "Safari"
set frontmost to true
keystroke "," using {command down} -- open preferences
delay 1
tell window "Security"
tell group 1
tell group 1
click checkbox "Block pop-up windows"
end tell
end tell
key code 53 -- close preferences
end tell
end tell
if you save it as popup.as you can run it like this:
$ osascript popup.as
Keep in mind that this only works locally, not on a cloud service like Sauce Labs.
Related
I recently moved away from Mac OS Sierra (yes I know I'm late) to High Sierra and I was forced to update to Safari Version 13.1.2. Now I am profoundly annoyed by it opening new Tabs (⌘t) next to my active tab instead of all to the right as it used to.
I believe while in Safari, using the keyboard shortcut ⌥ ⌘ T Will open a new tab to the far right
tell application "Safari" to activate
tell application "System Events" to tell process "Safari"
keystroke "t" using {option down, command down}
end tell
Knowing now that there is a menu entry "New Tab at End", there is no need for an Apple script or QuickSilver or anything. Just open System Preferences > Keyboard > Shortcuts, and add a shortcut using the plus button like the following:
So here is how to work around it. Open "Script Editor" and paste this code:
tell application "Safari"
if windows is {} then
make new document
else
tell first window
set current tab to last tab
tell application "System Events" to tell process "Safari" to tell menu bar 1 to tell menu bar item "File" to tell menu 1 to click menu item "New Tab"
end tell
end if
end tell
Disclaimer: this code is highly inspired by the code from xhinter on Mac OS X Hints, all kudos to him.
Save the script as Tab in Safari on the right.scpt in your ~/Library/Scripts folder (important for Quicksilver to find it). To run it you will need to allow rights to the app in the accessibility settings, the system will prompt you, don't discard it.
Check if Quicksilver > Catalog includes your user scripts, and refresh it to make sure the newly created script is in the catalog. Go to Triggers > Custom Triggers, add one via the plus in the bottom and type tabin, it will bring up the script as result. Enter closes the window. Press the ℹ️ in the bottom. Under Settings, add the Shortcut ⌘t. Under Scope, select Enabled in selected applications, in the textfield enter "Safari" which will be parsed automatically. See here for a more detailed description of scripts in Quicksilver.
That's it. Have fun!
I'm using Selenium with Robot Framework to write my GUI tests. One of the tests is verifying if, when the user clicks on the Close window/tab button (outside of the webpage), it triggers the alert box before exiting.
I've tried the keywords "Close window" and "Close browser", but both of them ignore the event and close the window. I also tried to close the window with javacript window.close();, but it doesn't work for windows that aren't opened with window.open(); - it is a security measure. I'm using Selenium Grid with different browsers on Linux and Windows, but everytime is failing. Is there a possibility to check this with selenium or I have to use other tools like AutoIT that automate any GUI, not only the browser?
After five days of searching for a solution, I didn't find one that tries to close the page/tab/window and triggers that alert confirmation box.
Instead, I found a workaround that is similar to that and also triggers the necessary alert which is captured by Selenium: click on a link, reopen the same page or go to another one. Like this:
Go To https://stackoverflow.com/
Handle Alert action=DISMISS
I put here action=DISMISS to simply continue with my test on the same page, but if there is need you can change it to something else.
im using selenium for automation, and in some part of the process im automation I get a system-pop up like this:
And I want to click on "ok", how can I do this?
thanks
ANSWER:
How to handle Javascript Alert/pop up window in selenium webdriver
Autoit provides windows GUI interaction.
Try AppleScript on macOS. It can handle the system pop-up.
tell application "System Events" to tell process "NotificationCenter"
click last item of windows
end tell
The example is how to click the system pop-up.
Maybe you can modify it for using on your case.
I need an applescript to open safari in full screen an to hide the toolbar on mavericks.
it sounds easy but it isnt!
i need to open safari then open google in full screen mode an then hide the toolbar.
it would be the equivilent to the below sample but instead for safari
tell application "Google Chrome"
open location "http://internet.ceo.wa.edu.au/Pages/default.aspx"
end tell
tell application "Google Chrome" to activate
tell application "System Events"
keystroke "f" using {command down, shift down}
end tell
Could be simple as this:
tell application "Safari"
activate
if (count of windows) is 0 then -- Remove "if" statement if you don't want to make a new window if there is none
make new document at front
end if
tell application "System Events" to keystroke "f" using {command down, control down}
end tell
Not sure if you can make it with no toolbar at all.
Update 4/4
not sure what you can do with it but look into this program. If it works the way you want. Add a system events to use the drop downs to select the item.
The Barbarian Group has a freeware app called "Plainview", which seems to be just a wrapper around Webkit. It works as a "Fullscreen kiosk-style presentation content viewer", similar to what Chrome presentation mode does.
Anyways, it's a free download, so no risk in trying. Scroll almost to the bottom of this page:
http://barbariangroup.com
Direct download:
http://s3.amazonaws.com/plainviewapp/plainview_1.0.178.zip
Easy way:
set MyApps to {"Google Chrome", "Skype", "Finder"}
repeat with MyApp in MyApps
tell application MyApp
activate
delay 3
tell application "System Events" to tell process MyApp
set value of attribute "AXFullScreen" of window 1 to true
end tell
end tell
end repeat
I'm new to applescript and is currently stuck in access the prompt window asking for my password.
I'm creating a launcher for my daily use application and i want to automate the launching process.
Right now, I'm only launching two application, VirtualHostX and MAMP. Later I might add few some.
Here's what I done so far:
tell application "VirtualHostX" to activate
tell application "MAMP" to activate
tell application "System Events"
tell process "VirtualHostX"
tell menu bar 1
tell menu bar item "Web Server"
tell menu 1
click menu item "Start"
end tell
end tell
end tell
end tell
end tell
When launching, It will launch the two application successfully, but Virtual Host will ask me for my password for authorization. I want to integrate entering my password in the flow or code. I already tried to google for answer but failed to find a solution for it.
I can't seem to target that window and enter my password.
Let me know what am I missing.
Thank You.
Password dialogs are shown by SecurityAgent:
tell application "System Events" to tell process "SecurityAgent"
set value of text field 2 of scroll area 1 of group 1 of window 1 to "password"
click button 2 of group 2 of window 1
end tell
For Yosemite, the SecurityAgent dialog box is different. This will work:
tell application "System Events"
tell process "SecurityAgent"
set value of text field 2 of window 1 to "yourPassword"
click button 2 of window 1
end tell
end tell