小妹初学selenium,在调用click时出现invalid argument: 异常
selenium吧
全部回复
仅看楼主
level 1
pumbkin灬 楼主
<span id="afc0" style="position:relative;display:block;width:300px;*width:300px;">
<input type="text" id="attachmentText0">
<input class="browse" type="button" value="浏览">
<input onchange="$('#attachmentText0').val(this.value)" size="19" type="file" name="attachmentFile" id="attachmentFile0" style="height:24px;opacity:0;filter:alpha(opacity=0);position:absolute;right:69px;top:2px;" class="">
<input type="button" value="上传" onclick="uploadAttachment(0);" class="upload-button">
</span>
-------------------------------------------------------------------------------------------------------------------------------------------------------
# 点击浏览,上传文件
file_ele = driver.find_element_by_xpath("//*[@id='attachmentFile0']")
file_ele.send_keys("C:\\Users\\tan.yadan\\Desktop\\测试图片\\1.jpg"
# 点击上传按钮
sleep(5)
upload_file = driver.find_element_by_xpath("//*[@id='afc0']/input[3]")
upload_file.send_keys(Keys.ENTER)
在调用程序时upload_file.send_keys(Keys.ENTER)报错,错误日志为:
想问问各位大佬,是什么原因导致的这个异常,也试过click方法也是报这个错,
打断点元素是能获取的到的,actionchains也用过,实在是找不到问题出在哪了,
哪位大佬有空能帮忙看一下,不胜感激!
2020年01月08日 07点01分 1
level 1
同问啊!!
2020年03月04日 05点03分 2
level 1
麻烦问下楼主解决没有。我能打开浏览器但是get url的时候就报这个错。也不说是哪个参数错了。跟你的信息一样。
2020年05月13日 01点05分 3
level 3
感觉上像是定位错了element,你重新看下是不是你xpath错了。可以试试 //input【@class=“upload-button”
2020年08月09日 06点08分 4
level 1
WebDriverWait(self.driver, 10).until(lambda browser: browser.find_element_by_xpath("//*[@id='app']/div[1]/div[2]/div/div[1]/div[2]/div/div[2]/div[2]/div[4]/div/div/div/div[2]/div/div/div[2]/input")).send_keys('C:\\Users\\admin\\Desktop\\XXXX.xlsx')
我之前忘记在文件名后加格式和你的报错一样,文件名后加了“.xlsx”之后就正常了
2020年10月27日 10点10分 5
正确
2021年05月14日 08点05分
level 1
self.driver.find_element_by_id('form-file-file').send_keys('B:\\申购品种xml.zip');
2021年05月14日 08点05分 6
1