我可以在硒运行时最小化Chrome窗口吗? [英] Can I minimize chrome window while selenium is running?

查看:95
本文介绍了我可以在硒运行时最小化Chrome窗口吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个项目可以从网站上获取一些信息. 我想看看chrome窗口中的过程,所以我不能使用无头浏览器.但是有时候我想最小化Chrome窗口.

I have a project to get some information from website. I want to look at the process inside the chrome window, So I can't use headless browser. But sometimes I want to minimize the chrome window.

但是我发现在手动最小化镀铬窗口后硒会出问题,但有时不会出问题.当出错时,例外

But I found the selenium would go wrong after I minimize the chrome window manually, but sometimes not. When go wrong, exception

该元素目前无法点击,其他元素将获得点击

element is not clickable at the point, other element will receive the click

会升高,或者硒有时会停止.

will be raised, or sometimes selenium just stop.

我已经搜索了很长时间,有人说应该通过单击窗口标题栏上的-"来关注chrome窗口,而不能将其最小化.替代解决方案是:

I have searched for a long time that some people said that the chrome window should be focused on and can't be minimized by clicking '-' on the window title bar. And the alternative solution is:

web.set_window_position(-2000,-2000)

web.set_window_position(-2000,-2000)

使窗口移出屏幕.

有人说通过模拟快捷方式来最小化窗口.但是我认为它与手动单击-"相同,对吗?

And someone says by simulating shortcuts to minimize the window. But I think it's the same as click '-' manually, am I wrong?

我的问题是:

  • 硒真的需要不最小化铬窗口吗?为什么有时在最小化后它可以正常运行硒,但有时却不能?
  • 如果我使用

  • Does selenium really requires chrome window not minimized? Why sometimes it can run selenium normally after minimized but sometimes not?
  • If I use

set_window_position(-2000,-2000)

set_window_position(-2000,-2000)

使窗口不可见,然后单击os底部的窗口图标(对不起,我不知道它叫什么).通常,单击时将最小化窗口.因此,对于此Chrome窗口,是否会将其视为最小化窗口并出问题了?

to move the window invisible, then I click the window icon on the bottom of os (I'm sorry that I don't know what it's called). Normally when clicked, the window will be minimized. So as for this chrome window, Will it be considered as minimized window and go wrong?

我真的很抱歉我的英语不好.希望我对我的问题有清楚的描述.

I am really sorry for my poor English. I hope I have a clear description of my problem.

环境:

  • python 3.6
  • chrome 66.0
  • 硒3.11.0
  • Windows Server 2012

编辑以添加代码:

wait.WebDriverWait(driver,100000).until(EC.visibility_of_element_located((By.ID,'commMgrCompositionMessage')))
        textArea = driver.find_element_by_id('commMgrCompositionMessage')
        driver.execute_script("arguments[0].value="+"'"+modelStr+"';",textArea)
        time.sleep(1)
        wait.WebDriverWait(driver,10000).until(EC.presence_of_all_elements_located((By.CSS_SELECTOR,'#sendemail_label')))
        allSendMailLabel = driver.find_elements_by_css_selector('#sendemail')
        allSendMailLabel = allSendMailLabel[1]
        driver.execute_script("arguments[0].click();", allSendMailLabel)

推荐答案

如果您在此处看到问题,请,则chromedriver中存在一个导致此错误的错误.它的问题是在此处创建的.第27条评论中列出了一种解决方法,但是您可以执行的操作是切换到firefox驱动程序,看看是否可行.最小化窗口应该不会引起问题.

If you see the question here Debugging "Element is not clickable at point" error, there is a bug in the chromedriver that causes this. The issue for it was created here. There is a workaround listed in the 27th comment, but what you can do is switch to the firefox driver and see if that works. Minimised windows should not cause a problem otherwise.

这篇关于我可以在硒运行时最小化Chrome窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆