Selecting saveas button when downloading file from browser - python

I've written a code with selenium and pyautogui to click around on a website and be able to click the save button with pyautogui after the download button has been clicked with selenium. I wanted to know if it was possible to click the saveas button instead and change the file name with python.
the code I have:
driver.find_by_element_by_xpath("//a[#id='Ribbon.Library.Action.ExportToSpreadsheet-Medium']").click()
saveButton = pyautogui.locateCenterOnScreen("C:\\User\\Documents\\savebutton.jpg")
pyautogui.click(position[0], position[1])
so what this does is click the download button and then compares the picture of the button and clicks the save option. But theres an arrow on the button to click saveas and that's what I need to click so I can choose the destination to save it and change the name of the file. Was wondering if there is a way to do this.
the button looks like this
also I am downloading from Edge, I'm not looking to use chrome or any other browser.

Related

Popup keeps loading after click using Python Selenium driver

I need to scrape a name and phone number that appears when clicking a button in a popup.
I was able to complete these steps:
Navigate through the site
Click on "Ver teléfono" option. This opens a popup
Fill the form
Click on "Enviar" option. This shows a loading gif and nothing else happens
Here is the used code: https://www.mycompiler.io/view/6ukTEftFwyh
The expected result (tested outside selenium) is that the popup shows the name and phone number after clicking the "Enviar" option

Using python and chromedriver, how to click on a specific button of a pop-up window when I cant find his ID?

I have a code in python that uses selenium chromedriver to reach a webpage and collect some data but I want to solve a issue related with a pop-up window. For example, if you go to this webpage https://finance.yahoo.com/quote/BAC?p=BAC you will get two pop-up windows. One is for the acceptance of the collection of personal data (image below) and this I can handle well with the following code:
...
# Go to the website:
driver.get(main_url)
# Click accept button
driver.find_element(By.NAME, "agree").click()
...
The second one (image below) however I'm not being able to dismiss. I want the code to click on the "Maybe later" button but I cant find the button ID. Can someone help me?

How to fetch text from the canvas loaded with game?

I am facing the situation where I have to automate certain stuff, the exact scenario is I have the game loaded in the canvas, and I can able to do the click actions inside the canvas(using Actionchains offset by selenium in python) but on click, there are certain actions happening on the game like it will display some values on button click and the values get changed on every click action of the button, Here I need to fetch those text(values).
By using selenium and python, I can able to achieve only the click actions, but what exactly I need is to fetch the text displayed on the canvas. Help will be much appreciated, Thanks in advance.

Python selenium a button can't be clicked

I am new for python selenium. I have been working for a script and I cannot press save gift options button. I used every ways(xpath css) but I couldn't. what should I do to press this button?
Snapshot of the button:
sometime x-path does not work. In my case every time buttons does not work when i find using x-path. You have to find button with it's ID and then apply click function.

Using python to download a file after clicking the generate icon

I am working on a project. Each day I need to login to a website. Navigate to a report page. After entering the require information, and clicking on the "gererate report" icon, there's a pop up windown asking me to save the file. I want to do it automatically by python.
I search the internet for a couple of days, and now I can do it by Autoit, but can't find a way in python.
By using urllib2, I can process up to clicking the "generate report" icon. But how can I get the name and location of the file and download it?
I want to make clear that the "generate report" button is actuary the submit button of a form. There is no Href associate with the generate button. After submitting the form, a file-save dialog popup asking me where to save the file.
thanks in advance!
If it's a save file dialog from Fx it probably means that it directly links to a file. If you manage to fill all the information and click the generate_report icon, can't you check which href has the generate_button assigned to it?
import urlib
urlfile = "Href of the generate_button"
urllib.urlretrieve(urlfile,"filename")

Categories