2017-04-05 107 views
0

我是新来的浏览器自动化。我想使用硒浏览器自动化来自动化网页,然后通过硒在Windows中执行一些工作来运行PowerShell脚本。我可以通过selenium使用firefox ide运行powershell脚本吗?

让我们假设,用硒ide我打开了一个网页,其中有一个IP,现在硒应该得到这个IP并传递给PowerShell,以便PowerShell脚本可以ping这个IP和PowerShell脚本的结果可以再次发送到硒以便它可以将该信息发送到网页以供提交。

新来硒等等,忽略任何错误

回答

1

需要打开页面后,复制你想要的IP,并用它来编写需要在电源外壳脚本命令。下面的示例代码#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复制响应并使用您想要的位置。如果您有任何问题,请告知我。

相关问题