Message quot;org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the XPath expressionquot; using sendKeys(消息“org.openqa.selenium.InvalidSelectorException:无效选择器:无法使用 XPath 表达式定位元素使用发送键)
问题描述
我在尝试使用 Selenium 上传文件时遇到问题.由于浏览按钮没有输入标签,我无法使用 sendKeys() 函数传递路径.它是用 Angular 编写的.
I am having trouble trying to upload a file using Selenium. I am not able to use the sendKeys() function to pass the path due to the browse button not having an input tag. It's written in Angular.
这是浏览按钮元素:
<a id="attachmentUpload-browse0" name="attachmentUpload-browse0" ng-click="clickBrowse($index)" class="btn-pri" xpath="1"></a>
我确实在源代码中的上述代码正下方找到了一个输入标签,但在尝试使用 .sendKeys()
时出现错误.
I did find an input tag right below the code above in the source, but I am getting errors when trying to use .sendKeys()
.
<input type="file" id="attachmentUpload-file0" name="attachmentUpload-file0" fileread="$parent.attachments[$index].fileData" class="attachmentUpload-inputfile ng-isolate-scope" onchange="angular.element(this).scope().onFileChange(this)" style="" xpath="1">
使用 .sendKeys() 输入标签时出错
Error when using .sendKeys() to input tag
Exception in thread "main" org.openqa.selenium.InvalidSelectorException: invalid selector: Unable to locate an element with the xpath expression //input[@id="attachmentUpload-file0"]// because of the following error:
SyntaxError: Failed to execute 'evaluate' on 'Document': The string '//input[@id="attachmentUpload-file0"]//' is not a valid XPath expression.
*** Element info: {Using=xpath, value=//input[@id="attachmentUpload-file0"]/
本文标题为:消息“org.openqa.selenium.InvalidSelectorException:无效选择器:无法使用 XPath 表达式定位元素"使用发送键
基础教程推荐
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 降序排序:Java Map 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01