from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
# driver
driver_path = r"C:\自己补齐\chromedriver.exe"
service = webdriver.chrome.service.Service(driver_path)
service.start()
# 启动应用
driver = webdriver.remote.webdriver.WebDriver(
command_executor=service.service_url,
desired_capabilities={
'browserName': 'chrome',
'goog:chromeOptions': {
'args': [],
'binary': r'D:\自己补齐\xxx.exe',
'extensions': [],
'windowTypes': ['webview']
},
'platform': 'ANY',
'version': ''
},
browser_profile=None,
proxy=None,
keep_alive=False
)
sleep(5)
# 拿handle数
len_handles = driver.window_handles
# 切换到当前启动的第一个窗口,解决多窗口,
driver.switch_to.window(len_handles[0])
# 操作
driver.find_element(By.XPATH, '先考虑完整路径的xpath后续再优化').send_keys('0333')
electron+selenium程序自动化实现(1)
于 2023-07-10 01:44:07 首次发布