Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ingognito and window size setting #4

Closed
punasusi opened this issue Mar 1, 2020 · 7 comments
Closed

ingognito and window size setting #4

punasusi opened this issue Mar 1, 2020 · 7 comments

Comments

@punasusi
Copy link

punasusi commented Mar 1, 2020

Is it possible to set chrome to use incognito mode, and also set the size of the window?

I know selenium can do this, but didn't find how to 'map' those options to helium.

@danbaghilovici
Copy link

danbaghilovici commented Mar 1, 2020

Helium has two functions : set_driver() and get_driver(). You can use a new selenium driver with the given arguments options to start helium with that given driver. For example :

from helium import *
from selenium import webdriver

chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--incognito")
chrome_options.add_argument("--window-size=600,300")
# or max
# chrome_options.add_argument("--start-maximized")
driver = webdriver.Chrome("./chromedriver", options=chrome_options)
set_driver(driver)
get_driver()
go_to("google.com")

After calling set_driver() there is no need to call start_chrome() since set_driver() already starts the given driver. Hope it helped.
I will probably add a PR later for suggesting that start_chrome() or start_firefox() take extra arguments for setting the drivers.
EDIT : code format

@mherrmann
Copy link
Owner

Thank you @dntzbgh! Re the pr: before you spend time on this, could you explain why it would be better than set_driver?

@danbaghilovici
Copy link

I guess its more straightforward than creating the driver instance with selenium and then setting it up with set_driver(). It will be much easier just to pass the arguments into start_chrome(url, options).

@punasusi
Copy link
Author

punasusi commented Mar 1, 2020

I don't think such a PR would give any technical benefits, but it would certainly be much more usable to just set any extra arguments directly in start_chrome(url, options).

@mherrmann
Copy link
Owner

Yeah, makes sense. Do you think you could add it for start_firefox too @dntzbgh ?

@danbaghilovici
Copy link

Hi, sorry for such a late response.
After thinking it better I think that what you have said in #9 makes sense. There are too many options and parameters to add it all one function and inserting it all in a webdriver.ChromeOptions object to the parameter wont help that much since if you have already configured an webdriver.ChromeOptions you might as well add it to a selenium driver and pass it to the set_driver() function. This way you have more flexibility with initialization of the driver parameters.

@mherrmann
Copy link
Owner

I've added an options parameter to start_chrome now. Please see release 3.0.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants