modal popup and marked blue left below
Is there any way to block modal(? - this is my understing for the box) popup automatically? I'm working on Mac, The bule color marked in left below is saying "do not open one day". I clicked check-box but it shows continuously. My searching result is such popup is called modal/layered popup - I have no idea for such technology. Please help how to block or click automatically by using Pythoin, javascript or Apple script. I'm using Keyboard maestro app so I can put such code before or after opening site which has modal(?) popup. I need to open 8-10 sites so need help.
tried to remove cookies but appear continuously. I think it's better click check-box automatically. Alternative if any is also good if can click "do not open one day" checkbox automatically.
Related
This has been asked before here: How to hide context click? Selenium Chromedriver
But none of the solutions there have worked for me. There is an element on my webpage that requires a right-click to select it (weird, but it makes sense with the site). I am able to click this element using
action.context_click(src).perform()
And I have tried to get rid of the menu that pops up after right-clicking 4 separate ways
# Left-clicking in the same spot after I have right-clicked
action.click().perform()
# Hitting the space bar
webdriver.ActionChains(self.driver).send_keys(Keys.SPACE).perform()
# Hitting the escape key
webdriver.ActionChains(self.driver).send_keys(Keys.ESCAPE).perform()
# Clicking on an unused element
action.move_to_element(WebDriverWait (self.driver, 10).until(EC.presence_of_element_located((By.TAG_NAME, "html"))))
action.click().perform()
# Reloading the page did not get rid of it either
self.driver.refresh()
None of these methods have worked to get rid of the menu that pops up. I cannot reload the page to get rid of this otherwise it will deselect the object I am trying to get. This does not affect my program but it is annoying to have it in my way when I am trying to spectate what my program is doing. Any help is appreciated! This is something in my free time so it is not time-sensitive.
I tried to open the context menu (right click) on a random site and then I was able to close it with pyautogui (pip install pyautogui)
action.context_click(src).perform()
import pyautogui
pyautogui.press('esc')
It may be possible that you have to press esc a couple of times.
I'm using selenium to try and automatically download a file each day.
I'm not able to get past this image though
I'm trying to use pyautogui to register where the "ok" button using this:
import pyautogui
pyautogui.screenshot('C:\\Users\\file location of screenshot')
pyautogui.locateCenterOnScreen('C:\\Users\\file location of screenshot of "ok" button')
Currently, I have a first screenshot of the whole message, and a second screenshot with the "ok" button where I want the click to happen.
However, because I have a blue light filter on my computer, the command doesn't to register the "ok" location on the computer and doesn't give me back coordinates of where the screenshot is on the screen.
Is there a way of automatically clicking on the "ok" button that might not get blocked by the blue light filter? Or even a way to help the computer recognize the "ok" button even with the blue light filter on?
Thanks!
I'm quite new in Python, and I'm creating a robot to export some reports from a system that is in Silverlight. Therefore, I can't use elements of the page to click/select/insert dates, etc.
Then, my solution was using pyautogui to move the mouse, click on the right buttons and save the files...
The process is:
-Select dates of the report
-Click on the "team" I need the report for
-Click on preview button (a new window opens here)
-Maximise this window which contains the report
-Click on 'Export' button (drop-down)
-Select 'Export to CSV'
And then, via code, get last downloaded file and move it into the folder where I save the reports.
The bottleneck on this is: sometimes, due to an unknown reason, 'Export' button is 20/'30 pixels aside. It means that the robot clicks in nowhere, and the code stops since there is no "last downloaded file" to handle.
I already noticed this second window (where the report opens) is not in Silverlight. It's simple HTML. I know I could use some methods in selenium to select the Export/Export to CSV option (similarly as I've done to login into this system). But my problem is: how do I refer to this new window?
The code I'm using refers to the main page using selenium.wedriver but I couldn't find a way to refer to the new window (that is closed after I downloaded the CSV. Then I click again in "Preview" and another window opens, and the process repeat hundreds of times)...
wsite='https://WEBSITE TO EXTRACT'
driver = webdriver.Ie('C:\\MyFolder\\IEDriverServer.exe')
driver.get(wsite) #opens the site
driver.find_element_by_id('userNameInput').send_keys('USERNAME')
driver.find_element_by_id ('passwordInput').send_keys('PASSWORD')
driver.find_element_by_id('submitButton').click()
Then, there are a lots of lines of code (where the mouse clicks where it's needed...
pyautogui.moveTo(1846,1000,intervaltoclick)#Preview button
pyautogui.click()
time.sleep(3)
hwnd = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
if i<1:
time.sleep(10+t)
else:
time.sleep(5+(t/5))
pyautogui.moveTo(566,52,intervaltoclick)#Export
pyautogui.click()
pyautogui.moveTo(603,205,intervaltoclick)#Save as CSV
pyautogui.click()
time.sleep(3)
pyautogui.moveTo(1270,1025,intervaltoclick)#close window
pyautogui.click()
Would someone have any idea on how can I do that?
You can try to keep the selenium object of IE browser that you used for login. You can keep it hidden if you don't want to show on a screen. You can than try to loop through the IE windows and switch to desired window.
Set<String> allWindowHandles = browser.getWindowHandles();
for(String handle : allWindowHandles)
{
System.out.println("Window handle - > " + handle);
browser.switchTo().window(handle);
System.out.println(browser.getTitle());
}
Here is a helpful link which shows the examples to switch the window.
Selenium WebDriver Switch Window Commands
The webpage I need to go to has a javascript popup message with an OK button that appears before the page can finish loading.
There's ways to get rid of the message by either clicking the button, pressing enter, pressing the x to close, or pressing ALT+F4. But all attempts to either click or press keys fails and just remains on the page with the popup.
I must be missing something.
Everything is current and installed, even the registry additions for the IE server executable.
Thanks
If this Java popup is generated by IE you could be able to handle it using Alert(driver).accept()
I have run into this issue a couple of times where the popup is not part of IE at all and this does not work. there are a couple different methods you can try to get around this:
try switching your browser to phantomJS (this is a headless browser that works with selenium and runs in the background so you will not be able to see what selenium does anymore but it often will eliminate popups and is good if you don't actually need to click the popup)
try using the mouse or keyboard packages to hit that button.
I'm calling a apple script dialog from python as so:
import subprocess
applescript = """
display dialog "Some message goes here..." ¬
with title "This is a pop-up window" ¬
with icon caution ¬
buttons {"OK"}
"""
subprocess.call("osascript -e '{}'".format(applescript), shell=True)
However, based on certain conditions of my app, the notifications may go into the 100s i.e., too many dialogs may get queued up and dismissing each one manually by clicking on their respective "OK" buttons wouldn't be feasible. So what I'm looking for is a another apple script that I can use probably straight from the applescript editor that can clear these dialogs for me. A bonus would be to capture their text & timestamps into a text file, but just clearing them is something I need.
I'm new to Mac/applescipts and have not found a valid solution. I've tried the following:
tell application "System Events"
tell process "NotificationCenter"
set numwins to (count windows)
repeat with i from numwins to 1 by -1
click button "OK" of window i
end repeat
end tell
end tell
and
tell application "System Events"
click button 1 of windows of application process "TextEdit"
end tell
Can someone guide me in terms of how to achieve this? Thanks!
Alternately,
If there is a way to "separate" notifications for each iteration of:
b = """
display notification "All graphics have been converted 2." with title "My Graphic Processing Script" subtitle "Processing is complete." sound name "Frog"
"""
subprocess.call("osascript -e '{}'".format(a), shell=True)
then, that would work as well. Currently what's happening is each iteration of the notification is stacking on top of each other- ie., when multiple of them gets generated, I only see the latest one, or the number of such notifications. I instead would like to see all the notifications- perhaps have them stacked vertically- for eg: first notification displays in top right, and when second notification appears before the first disappears then, the first notification can get pushed downwards and the second one can be displayed on top of that. Similarly the third one can push both the first and second downward and then be on top of them and so forth.
Can this be achieved?
Basically, I need to see the content of all such notifications- either passively or actively requiring clicks. But in both cases, dismissing the notification should not impede my work. This is a monitoring application so based on certain conditions it would throw notifications my way- which the more close to real time, the better- so thats why I need to view all my notifications, as they appear, rather than write to some csv or txt file and me physically check that file periodically- which would be an unsustainable work flow.
I don't fully understand what you're trying to accomplish. If you don't like having dialogs, why are you putting dialogs in your script.
Anyhow, here are a couple ideas:
Add
giving up after 1
to your display dialog command, which will dismiss each box automatically after 1 second.
In place of the dialog box, how about putting instead a command to write a time stamp or whatever to a text file. Then you can check the text file to see it all worked.