question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

allow --force-device-scale-factor=1 as setting in seleniumbase

See original GitHub issue

Hi, I want to run my tests on GitHub Actions CI and I am writing the tests locally on macos. The retina display that I am using consistently doubles width and height.

I addressed this by crudely monkeypatching get_new_driver of BaseCase:

from selenium import webdriver
from seleniumbase import BaseCase


class ComponentsTest(BaseCase):
    def get_new_driver(self, *args, **kwargs):
        """ This method overrides get_new_driver() from BaseCase. """
        options = webdriver.ChromeOptions()
        options.add_argument("--force-device-scale-factor=1")    # fix macos retina displays
        if self.headless:
            options.add_argument("--headless")
        driver = webdriver.Chrome(options=options)
        width = 1920
        height = 1080
        driver.set_window_size(width, height)
        print('Window size', driver.get_window_size())
        return driver

But this is a very crude solution and it broke on my second test case when I used self.click. How can I cleanly enable any google chrome browser option that I can pass to selenium.webdriver in that way, also work in seleniumbase?

I found custom_settings.py but I don’t know if that is the right place?

Using those works to set the width and height:

CHROME_START_WIDTH = 1920
CHROME_START_HEIGHT = 1080
HEADLESS_START_WIDTH = 1920
HEADLESS_START_HEIGHT = 1080

Can I somehow set force-device-scale-factor=1 with seleniumbase --chromium-arg and can you point me to the correct syntax? I can’t figure it out.

Help appreciated, thank you 😃

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
svenstehlecommented, May 3, 2022

Awesome, that looks good! I think that will help a few newbies like me a lot. Thanks 😃

1reaction
mdmintzcommented, May 3, 2022

@svenstehle I just made some changes:

https://github.com/seleniumbase/SeleniumBase/commit/30eafb00d2023e2c4833e34e4636c8147554963e

--chromium-arg="ARG=N,ARG2"  # (Set Chromium args, ","-separated, no spaces.)
--firefox-arg="ARG=N,ARG2"  # (Set Firefox args, comma-separated, no spaces.)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Syntax Formats - SeleniumBase Docs
A complete framework for end-to-end testing with Python, pytest, behave-BDD, and WebDriver.
Read more >
SeleniumBase/settings.py at master - GitHub
Python framework for web automation and testing that extends Selenium. - SeleniumBase/settings.py at master · seleniumbase/SeleniumBase.
Read more >
seleniumbase/SeleniumBase - Gitter
tests/commons/base.py:72: in setUp super(BaseTestCase, self).setUp() venv/lib/python3.7/site-packages/seleniumbase/fixtures/base_case.py:3267: in setUp ...
Read more >
Selenium Python using SeleniumBase Framework - YouTube
... this 3 hours full course for Selenium Python using SeleniumBase Framework, we will be covering everything from setting up your...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found