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

Trying to get Steward working with headless #233

Closed
ShabariRepo opened this issue Nov 5, 2018 · 1 comment
Closed

Trying to get Steward working with headless #233

ShabariRepo opened this issue Nov 5, 2018 · 1 comment

Comments

@ShabariRepo
Copy link

Hi all,

This may just be a quick inquiry but im trying to get headless working with steward simple test. Im sure im just missing something stupid

Scenarios:

  1. Non steward tests using just phpunit works with headless
    ./vendor/phpunit/phpunit/phpunit --verbose -c ./TestAch.xml

Test Setup

public function setUp()
    {
        $options = new ChromeOptions();
        
        $desired_capabilities = new DesiredCapabilities();
        $desired_capabilities->setBrowserName('chrome');
        $caps = DesiredCapabilities::chrome();

        $options->addArguments(['--headless', '--window-size=1920,1080', '--start-maximized']);
        $desired_capabilities->setCapability(ChromeOptions::CAPABILITY, $options);

        $caps->setCapability(ChromeOptions::CAPABILITY, $options);

        $capabilities = DesiredCapabilities::chrome();

        $this->_webdriver = RemoteWebDriver::create(
            'http://localhost:4444/wd/hub',
            $caps
        );
    }
  1. Steward tests with passed params (capabilities) doesnt open in headless (opens browser)
    ./vendor/bin/steward run staging chrome --capability "'chromeOptions':'args':['--headless', 'window-size=1024,768', '--no-sandbox']"
@OndraM
Copy link
Member

OndraM commented Nov 6, 2018

Hi, you cannot change desired capabilities inside the test (neither in the setUp method), because the moment tests begins, the browser is already opened.

For now, you'd need to create custom capabilities resolver, which would trigger the headless mode on startup.
It should be quite easy though: see documentation here: https://github.com/lmc-eu/steward/wiki/Set-custom-capabilities#implement-custom-capabilities-resolver
And we are doing exactly this (starting chrome headless mode) in our example project:
https://github.com/lmc-eu/steward-example/blob/feature/next/src/CustomCapabilitiesResolver.php#L51

However I will create issue to think about easier way how to do this in futures.

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

2 participants