Python selenium automates the method of writing body in email

The body of the email is an iframe, first switch to this iframe, and then directly locate the body element ('/html/body') in this iframe, and then use the following method 1 or method 2 to enter the content.
Method 1: Use element.send_keys('Hello') can write the content directly
Method 2: Write the content with js statement driver.execute_script("document.getElementsByTagName('body')[0].innerHTML=' Hello ;' ")

When none of the above methods are available, you can try the following methods:
first focus on the subject bar of the email, and then use the subject bar element to switch the focus element.send_keys(Keys.TAB), this function can be executed multiple times, until the text box is switched , And then setText('Hello') through the clipboard, and paste into the text box with keyDown('ctrl') and keyDown('v')

Guess you like

Origin blog.csdn.net/weixin_44123630/article/details/113852949