我尝试使用以下方法查找元素:
self.s2l.execute_javascript(
'document.getElement(By.XPath"{}")[0].scrollBy(0,{})'.format(
element,
new_position
)
出现错误:
JavascriptException: Message: javascript error: missing ) after argument list
当我使用:
self.s2l.execute_javascript(
'document.getElementsByClassName("{}")[0].scrollBy(0,{})'.format(
element,
new_position
)
工作和测试通过
你能帮我看看Xpath到底出了什么问题吗
在
By.XXX()
的参数周围需要括号。另外,在By
和定位器类型之间有一个.
你有不平衡的括号,你缺少了与
self.s21.execute_javascript
之后的(
匹配的)
。(我不知道为什么你的第二个例子没有同样的问题)另外,
xpath
在JavaScript中是小写的如果XPath表达式包含引号,请不要使用分隔XPath的同一种引号,然后对它们进行转义以避免它们结束包含JavaScript的字符串
相关问题 更多 >
编程相关推荐