参数未应用于带有 python 的 Selenium 中的 Google chromedriver [英] Arguments not being applied to Google chromedriver in Selenium with python

查看:20
本文介绍了参数未应用于带有 python 的 Selenium 中的 Google chromedriver的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 OS X (Yosemite) 上使用 selenium 和 python 和 chromedriver (webdriver)

I'm using selenium with python and chromedriver (webdriver) on OS X (Yosemite)

我正在尝试向我的驱动程序实例添加参数,如下所示:

I'm trying to add arguments to my driver instance like so:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--start-maximized')
webdriver.Chrome(executable_path='/Library/Python/2.7/site-packages/selenium/webdriver/chrome/chromedriver', chrome_options=chrome_options)

浏览器窗口创建得很好,但没有最大化.

The browser window creates fine but it doesn't maximise.

即使忽略那个特定的论点,无论我提供哪些论点,它们似乎都没有得到应用.我错过了什么吗?

Even ignoring that particular argument, no matter which arguments I supply they never seem to be applied. Am I missing something?

似乎我可以毫无问题地通过移动仿真选项.因此,问题可能包含在传递参数类型选项上.

Seems I can pass the mobile emulation options without any problems. So the issue might be contained to passing argument type options.

推荐答案

您做得对,--start-maximized 在 mac 上不起作用.

You are doing it correctly, --start-maximized just doesn't work on mac.

要最大化 chrome 窗口 - 使用 <代码>maximize_window():

To maximize the chrome window - use maximize_window():

maximize_window()

最大化 webdriver 正在使用的当前窗口

Maximizes the current window that webdriver is using

driver.maximize_window()

这篇关于参数未应用于带有 python 的 Selenium 中的 Google chromedriver的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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