update: wait until frame available
This commit is contained in:
12
邮件批量发送脚本.py
12
邮件批量发送脚本.py
@@ -223,22 +223,24 @@ def main():
|
||||
print(f'[信息] 正在发送:{recipient}')
|
||||
click("button[aria-label='Edit copy']")
|
||||
|
||||
# 等待页面加载
|
||||
ready(driver, lambda x: x.find_element(By.CSS_SELECTOR, ".io-ox-busy"))
|
||||
|
||||
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)
|
||||
locate("div.io-ox-mail-compose-window iframe", condition=EC.frame_to_be_available_and_switch_to_it)
|
||||
action = ActionChains(driver).send_keys(Keys.END)
|
||||
|
||||
if name is not None and (name := str(name).strip().title()) and not contains_non_latin_alphabet(name):
|
||||
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]])
|
||||
|
||||
action = ActionChains(driver).send_keys(Keys.END)
|
||||
for attempt in range(args.retry): action.perform()
|
||||
ActionChains(driver, 5000).send_keys(Keys.SPACE).send_keys(firstname).perform()
|
||||
if delimiter := str(args.delimiter).strip():
|
||||
for attempt in range(args.retry): action.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)
|
||||
keyin(to, recipient)
|
||||
|
||||
Reference in New Issue
Block a user