I am creating a browser automatic operation program with Selenium.
I want to process only a part of the program automatically during browser operation.
For example, until the ticket selection on the airline site
It is assumed that I want to operate the browser yourself but want to automate the subsequent payment procedure with a program.
In such a case, is there a good way to let the program control the window being operated?
I'm concerned that only browsers launched on the program can be processed by the program ...
If the above concerns are positive, as an alternative
I am happy even if I can behave as follows.
1. Run the program and launch the browser
2. Allow the user to interact while running in some way
3. The program continues with some input
Please point out if there is a lack of explanation.
Answer # 1
How about trying switch_to_window?
from selenium import webdriver from selenium.webdriver.common.keys import Keys import pprint driver = webdriver.Chrome ('pathtodriver') driver.get ('https://www.yahoo.com') time.sleep (1) driver.find_element_by_name ('p'). send_keys ('Selenium Python3') driver.find_element_by_name ('p'). send_keys (Keys.ENTER) time.sleep (1) driver.find_element_by_css_selector ('# web>ol>li: nth-child (1)>div>div>h3>a'). click () pprint.pprint (driver.title) driver.switch_to.window (driver.window_handles ) # go next window pprint.pprint (driver.title) driver.switch_to.window (driver.window_handles ) # go back window pprint.pprint (driver.title)
Answer # 2
Another method is to use pyautogui.
Reference link: Let PyAutoGui do repeated work with Python
Although it feels unreasonable, I like the mouse and keyboard itself, so I like it intuitively.
There is also an image recognition function, so you can specify the position of the button.
import pyautogui as pa
- operate a chrome window that is already open with vba selenium
- ruby on rails - [ruby] selenium (chrome failed to start: exited abnormally) error
- selenium google chrome page "always leave this site" alert measures at the time of page transition
- cannot sendmessage on the tab at the bottom of the window immediately after creating the chrome extension
- i want to scrape with selenium using headless chrome on vps
- chrome - let me use selenium
- can't log in to chrome in new window with proxy
- cannot specify selenium chromedriver path
- vba - how to specify browser window in selenium basic
- whether or not you know that "chrome launched with selenium"
- chrome - python selenium i want to get the first detected a tag of grandchild element
- python 3x - i want to install chrome extension with selenium and python
- python - when using selenium in chrome, i want to apply the smartphone version of developer tools
- python - in selenium, the window size does not exceed the pc display size
- i want to launch headless chrome with selenium using python on ubuntu
- in selenium + python, i want to transition to a new window where an alert appears
- c # - can't change chrome profile on selenium
- i want to move the tab focus in selenium ide for chrome extension
- chrome - i want to operate chromium with selenium
- python - i get a mysterious error for some reason
- python 3x - is it possible to get "specific value selected event" in tkinter combo box in python?
- python - i want to know how to eliminate no module named'flask'
- python - i want to create a shortcut in a specific folder
- python - unicodedecodeerror when installing pip on windows
- i have python and pip installed on windows, but i can't install using pip
- regarding arguments for superclass constructors in python tkinter
- error occurs in getelement method of htmlobject obtained from win32comclient in python37
- python 3x - unclear code in tkinter (python) written in object-oriented