update: wait until frame available
This commit is contained in:
12
邮件批量发送脚本.py
12
邮件批量发送脚本.py
@@ -223,22 +223,24 @@ def main():
|
|||||||
print(f'[信息] 正在发送:{recipient}')
|
print(f'[信息] 正在发送:{recipient}')
|
||||||
click("button[aria-label='Edit copy']")
|
click("button[aria-label='Edit copy']")
|
||||||
|
|
||||||
# 等待页面加载
|
|
||||||
ready(driver, lambda x: x.find_element(By.CSS_SELECTOR, ".io-ox-busy"))
|
ready(driver, lambda x: x.find_element(By.CSS_SELECTOR, ".io-ox-busy"))
|
||||||
|
locate("div.io-ox-mail-compose-window iframe", condition=EC.frame_to_be_available_and_switch_to_it)
|
||||||
wrapper = locate("div.io-ox-mail-compose-window div[data-extension-id='to'] > div.mail-input")
|
action = ActionChains(driver).send_keys(Keys.END)
|
||||||
to = locate("input.token-input.tt-input[tabindex='0']", parent=wrapper)
|
|
||||||
|
|
||||||
if name is not None and (name := str(name).strip().title()) and not contains_non_latin_alphabet(name):
|
if name is not None and (name := str(name).strip().title()) and not contains_non_latin_alphabet(name):
|
||||||
parts = name.split()
|
parts = name.split()
|
||||||
firstname = parts[0] if len(parts) == 1 or (len(parts[0]) > 3 and '.' not in parts[0]) else " ".join([parts[0], parts[1]])
|
firstname = parts[0] if len(parts) == 1 or (len(parts[0]) > 3 and '.' not in parts[0]) else " ".join([parts[0], parts[1]])
|
||||||
|
|
||||||
action = ActionChains(driver).send_keys(Keys.END)
|
|
||||||
for attempt in range(args.retry): action.perform()
|
for attempt in range(args.retry): action.perform()
|
||||||
ActionChains(driver, 5000).send_keys(Keys.SPACE).send_keys(firstname).perform()
|
ActionChains(driver, 5000).send_keys(Keys.SPACE).send_keys(firstname).perform()
|
||||||
if delimiter := str(args.delimiter).strip():
|
if delimiter := str(args.delimiter).strip():
|
||||||
|
for attempt in range(args.retry): action.perform()
|
||||||
ActionChains(driver, 5000).send_keys(delimiter).perform()
|
ActionChains(driver, 5000).send_keys(delimiter).perform()
|
||||||
|
|
||||||
|
driver.switch_to.default_content()
|
||||||
|
wrapper = locate("div.io-ox-mail-compose-window div[data-extension-id='to'] > div.mail-input")
|
||||||
|
to = locate("input.token-input.tt-input[tabindex='0']", parent=wrapper)
|
||||||
|
|
||||||
# 填入收件人
|
# 填入收件人
|
||||||
click(wrapper)
|
click(wrapper)
|
||||||
keyin(to, recipient)
|
keyin(to, recipient)
|
||||||
|
|||||||
Reference in New Issue
Block a user