我可以用firefox ide通过selenium运行powershell脚本吗?

时间:2017-04-05 02:33:05

标签: powershell selenium

我是浏览器自动化的新手。我想使用selenium浏览器自动化来自动化网页,然后通过selenium运行一个PowerShell脚本,它将在windows中完成一些工作。

让我们假设,在selenium ide中我打开了一个有IP的页面,现在selenium应该得到这个IP并传递给powershell,以便powershell脚本可以ping这个IP并且powershell脚本的结果可以再次发送到selenium所以它可以将该信息发送到网页进行提交。

新的Selenium所以,忽略任何错误

1 个答案:

答案 0 :(得分:1)

打开所需页面后,复制所需的IP并使用它在power shell脚本中编写require命令。下面的示例代码#python可能对您有用

from subprocess import Popen
def createandExecuteFile(self):
    file = open("path to powershell  script", "w+")
    file.write("write command for powershell")
    file.close()
    p = Popen(["powershell.exe", "path to powershell script"], stdout=sys.stdout)
    p.communicate()

从powershell复制响应并使用您想要的位置。如果您有任何问题,请告诉我。