Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/316.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Python Selenium通过javascript获取元素_Javascript_Python_Selenium_Webdriver - Fatal编程技术网

使用Python Selenium通过javascript获取元素

使用Python Selenium通过javascript获取元素,javascript,python,selenium,webdriver,Javascript,Python,Selenium,Webdriver,我尝试使用如下javascript在python selenium中获取列表 lists = browser.execute_script("document.getElementById('permalink-overlay').getElementsByClassName('u-dir')") 但是,终端显示“非类型”对象的错误 如何通过javascript从python selenium中获取列表?您做错了 lists = browser.execute_script("var x =

我尝试使用如下javascript在python selenium中获取列表

lists = browser.execute_script("document.getElementById('permalink-overlay').getElementsByClassName('u-dir')")
但是,终端显示“非类型”对象的错误

如何通过javascript从python selenium中获取列表?

您做错了

lists = browser.execute_script("var x = document.getElementById('permalink-overlay').getElementsByClassName('u-dir'); return x;")

或者类似的内容

用相关的HTML更新问题