Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.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
Javascript PhantomJS执行脚本在python Selenium headless测试中返回None_Javascript_Python_Selenium_Selenium Webdriver_Phantomjs - Fatal编程技术网

Javascript PhantomJS执行脚本在python Selenium headless测试中返回None

Javascript PhantomJS执行脚本在python Selenium headless测试中返回None,javascript,python,selenium,selenium-webdriver,phantomjs,Javascript,Python,Selenium,Selenium Webdriver,Phantomjs,我正在用下面的代码对我的一个示例应用程序进行无头测试 无法使用send_键上载文件,所以实际上尝试使用在python中的PhantomJS web驱动程序中执行的Javascript在页面上选择元素 driver.execute\u脚本('document.querySelector(“input[type=file]”)) 上面的代码在python中总是返回None对象。其中,在浏览器控制台中执行document.querySelector(“input[type=file]”,生成输入文件类

我正在用下面的代码对我的一个示例应用程序进行无头测试 无法使用send_键上载文件,所以实际上尝试使用在python中的PhantomJS web驱动程序中执行的Javascript在页面上选择元素

driver.execute\u脚本('document.querySelector(“input[type=file]”))

上面的代码在python中总是返回
None
对象。其中,在浏览器控制台中执行
document.querySelector(“input[type=file]”
,生成输入文件类型元素


为什么我总是用PhantomJS execute_脚本在python中找不到类型?

execute_脚本
没有返回值:感谢@Amber的快速响应。。这节省了很多时间。你知道如何使用带有phantomJS的SeleniumWeb驱动程序上传文件吗。尝试了很多选择,但运气不佳。使用send_键。。没有响应返回,并在发送键本身停止。当然,我为同一问题记录了StackOverFlow问题。