相关疑难解决方法(0)

在 Selenium ChromeDriver 中隐藏命令提示符

var driverService = ChromeDriverService.CreateDefaultService();
driverService.HideCommandPromptWindow = true;

var driver = new ChromeDriver(driverService, new ChromeOptions());
Run Code Online (Sandbox Code Playgroud)

是否有可能在 Python 中实现这一点?我已经尝试了在 StackoverFlow 和外部发布的所有可能的修复程序,但是当我运行我的 .exe 时什么也没有,cmd 也出现了。

Python 3.6,最新的 Selenium 版本 (3.9)。

python selenium selenium-webdriver

6
推荐指数
1
解决办法
8485
查看次数

使用pythonw.exe时,Python subprocess.call()失败

当我使用python.exe运行它时,我有一些Python代码可以正常工作,但如果我使用pythonw.exe则会失败.

    def runStuff(commandLine):
        outputFileName = 'somefile.txt'
        outputFile = open(outputFileName, "w")

        try:
            result = subprocess.call(commandLine, shell=True, stdout=outputFile)
        except:
            print 'Exception thrown:', str(sys.exc_info()[1])

    myThread = threading.Thread(None, target=runStuff, commandLine=['whatever...'])
    myThread.start()

我收到的消息是:

    Exception thrown: [Error 6] The handle is invalid

但是,如果我没有指定'stdout'参数,则subprocess.call()启动正常.

我可以看到pythonw.exe可能正在重定向输出本身,但我不明白为什么我被阻止为新线程指定stdout.

python multithreading subprocess

5
推荐指数
2
解决办法
5280
查看次数