###########
userful selenium
###########
confirm window でログインは下記フォマードで
new_url = 'http://{}:{}@{}'.format(username, password, url)
http://username:password@url
download window を開けないように設定
オプション(firefox用)
from selenium.webdriver.firefox.options import Options
#Firefox WebDriver (FireFoxで実施)
options = Options()
options.set_preference("browser.download.folderList",2)
#options.set_preference("browser.download.dir", downloadPath)
options.set_preference("browser.download.manager.showWhenStarting",False)
options.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/octet-stream")
options.set_preference("general.useragent.override", "URL Check")
driver = webdriver.Firefox(options=options)
frame移動
frame = driver.find_element_by_name("Web-Page")
driver.switch_to.frame(frame)
driver.switch_to.window(handle)
driver.switch_to.default_content()
------アラートフォームの処理
driver.switch_to.alert.accept()
driver.switch_to.alert.dismiss()
---------scroll&radio-----
target=driver.find_element_by_css_selector("div.bg-w.van-row>div:nth-child(15) div.m-t-5.c-3")
driver.execute_script("arguments[0].scrollIntoView();", target)
#elements = driver.find_elements_by_css_selector("input[type='radio'][name='radio_progid_cd']")
#for elem in elements:
# elem.click()
# print(elem.get_attribute("value"))
#if elem.get_attribute("value") == "ZMSD0020":
#elem.click()
#driver.find_element_by_xpath('//input[@name="radio_progid_cd" and value="ZMSD0020"]').click()
#driver.find_element_by_name("radio_progid_cd").click()
#driver.find_elements_by_name('radio_progid_cd')[10].click()
标签:name,selenium,driver,options,radio,userful,find,preference
From: https://www.cnblogs.com/z20240722/p/18315953