upload.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> <h1>hello worlds</h1> <form action="/klvchen/" method="post" enctype="multipart/form-data"> <p><input type="file" name="upload"></p> <p><input type="submit" value="submit"></p> </form> </body> </html>
使用click element 操作上传文件按钮,会报错提示InvalidArgumentException: Message: invalid argument
Clicking element ${upload} 20210916 16:30:57.666 : INFO : Clicking element 'id=upload'. 20210916 16:30:57.801 : INFO : </td></tr><tr><td colspan="3"><a href="selenium-screenshot-1.png"><img src="selenium-screenshot-1.png" width="800px"></a> 20210916 16:30:57.804 : FAIL : InvalidArgumentException: Message: invalid argument
改为模拟按键按下:按下 抬起
Selenium2Library.Mouse Down ${upload} Selenium2Library.Mouse Up ${upload}