Automated test processing textarea text box

Front-end code example:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <textarea class="textarea" style="width:100px;height:100px">
    </textarea>
</body>
</html>

Although we can locate it by class, we cannot enter text information into the text box through send_keys(). In this case, you need to use JavaScript code to complete the input.

Insert picture description here

text="inout text"
js = "var sum=document.getElementById('id');sum.value='" + text +'';"
driver.execute_script(js);

First define the content text to be input, and then splice the text and JavaScript code through "+". The purpose of this is to make the input content customizable. Finally, the JavaScript code is executed through execute_script().

Guess you like

Origin blog.csdn.net/Python_BT/article/details/108446404