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

Example of how to set chrome option #90

Open
localnerve opened this issue Apr 27, 2017 · 1 comment
Open

Example of how to set chrome option #90

localnerve opened this issue Apr 27, 2017 · 1 comment

Comments

@localnerve
Copy link

Hello, thanks for this very easy to use library - It's great, actually.

Unfortunately, I'm struggling to get the chrome driver to confirm (echo back) that it has its mobileEmulation option set. No matter what I try, it keeps showing me that the mobileEmulationEnabled capability is false.

Wondering if someone already has done this and can share an example or direct me.

What I'm actually trying to do is emulate a swipe left:

driver.touchActions()
    .tapAndHold({ x: 250, y: 250 })
    .move({ x: -240, y: 250 })
    .release({ x: 10, y: 250 })
    .perform();

But I get an error about the move, and I presume that it is because the hasTouchScreen capability is false, and I further presume that is because mobileEmulationEnabled is false (the driver confirms the settings via driver.getCapabilities). All in all, I'm feeling over-extended on presumptions :-). Any assistance you can lend is much appreciated.

FWIW, I've seen this and am setting addCapability prior to getSeleniumDriver functionally similar to this:

let globalDriverReferences;
const automatedBrowsers = seleniumAssistant.getLocalBrowsers();
Promise.all(automatedBrowsers.map(browserInfo => {
  // Set all chrome browsers to emulate iPhone 6
  if (browserInfo.getId() === 'chrome') {
    browserInfo.addCapability('mobileEmulation', { deviceName: 'iPhone 6' });
  }
  return browserInfo.getSeleniumDriver();
})).then(drivers => { globalDriverReferences = drivers; });

Here's how I get Chrome Driver to confirm its current capabilities:

chromeDriver.get(someUrl)
.then(() => chromeDriver.getCapabilities())
.then(capabilities => {
  capabilities.forEach((value, key) => {
    console.log('capability entry: ', key, value);
  });
});
@gauntface
Copy link

This could be a bug in selenium-assistant.

One thing I didn't realise when writing this (and later discovered with Saucelabs) is that capabilities + calling withBrowser() is that one will override the other. I don't think I ever propagated the changes over to local browsers.

If I get a chance I'll dig around and see if there is anything I can find / fix.

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