[英]Missing error after argument list - Selenium Python (executing Javascript)
I've been at this for a while now, I know there are some questions along the lines of this one but I cannot figure out where on earth my string isn't escaped correctly or needs more quotes.我已经有一段时间了,我知道有一些问题与此有关,但我无法弄清楚我的字符串到底在哪里没有正确转义或需要更多引号。
I have this line我有这条线
self.driver.execute_script("$x('//div[text()=\'Find Artwork\']')[0].click()")
and this works perfectly in the console这在控制台中完美运行
$x('//div[text()=\'Find Artwork\']')[0].click()
However when running in Python with Selenium + Chrome webdriver I get this error但是,当使用 Selenium + Chrome webdriver 在 Python 中运行时,出现此错误
selenium.common.exceptions.JavascriptException: Message: javascript error: missing ) after argument list
Unsure quite what to do here.不确定在这里做什么。 I've tried double quotes, escaping, everything.
我试过双引号,escaping,一切。
Thanks!谢谢!
$x
is not part of JavaScript, but just a utility in cosole of firefox and chrome. $x
不是 JavaScript 的一部分,而只是 firefox 和 chrome 的控制台中的一个实用程序。
See this question .看到这个问题。
You can try something like this:你可以尝试这样的事情:
javaScript = "document.getElementsById('username')[0].click();"
driver.execute_script(javaScript)
//or
driver.execute_script("arguments[0].click()", element);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.