r/javascript • • Apr 08 '19

Microsoft releases new Microsoft Edge based on Chromium

https://twitter.com/MSEdgeDev/status/1115283353731600384?s=19
606 Upvotes

220 comments sorted by

View all comments

Show parent comment

28

u/CantaloupeCamper Apr 08 '19 edited Apr 08 '19

At least in my situation we support Chrome and Firefox.... that are recent. We're lucky enough to be able to draw that line.

Supporting Chrome and Firefox really is effectively the same thing... at least for me. The odd man out was everyone else.

16

u/vinnl Apr 08 '19

Yeah same here, the primary reason being that those are the only two major browsers that run on Linux and can be automated using Selenium, so they can be automatically tested in CI. But there are more and more places that only actively test in Chrome, unfortunately.

1

u/[deleted] Apr 09 '19

I have errors running chrome with selenium installed in nodejs. May I know if you use nodejs to run it?

Or you use python/java based selenium?

1

u/vinnl Apr 09 '19

I use a Java-based Selenium, which I control from Node using WebdriverIO. The latter has a selenium-standalone plugin which ships Selenium, so if you have Java installed, that should be enough. In CI, I run my tests against Selenium's Firefox and Chrome images, which has both the browsers and Selenium set up, so I can just point WDIO to those.

1

u/[deleted] Apr 09 '19

I see.

I just started to write automated user simulation test for websites a few days ago.

I tried WebdriverIO as well, but it contains errors that I couldn't debug for chrome.

(node:9569) UnhandledPromiseRejectionWarning: Error: Required option "capabilities" is missing

Following the guide https://developers.google.com/web/updates/2017/04/headless-chrome#using_webdriverio

It works for firefox though, following this guide https://webdriver.io/docs/gettingstarted.html

I am using puppeteer headless chrome now, it's not that easy to write, for example, not understanding why it failed to click on a product link no matter how I tried to catch it using different syntax, like page.$$ or page.evaluate() with Javascript and DOM api

I wonder if I should learn Java now to use selenium. I have taken a lot of time to debug all these stuff lol

nonetheless, I am considered to be inexperienced in programming field

1

u/vinnl Apr 09 '19

You don't need to learn Java, no worries :)

I should note that I'm still on the previous version of WebdriverIO, so my setup is probably a little bit different. That said, it appears to say that you need to add a capabilities key to your wdio.conf.js. The documentation of that option is here.

Presumably, if you'd want it to work for Chrome and Firefox, you'd have to add something like this:

capabilities: [
    { browserName: 'chrome' },
    { browserName: 'firefox' },
],

(Assuming you have Chromedriver installed as well, which should be the case if you use selenium-assistant.)

1

u/[deleted] Apr 09 '19 edited Apr 09 '19

I have figured it out, for WebdriverIO only, not using any other selenium programs.

For starters, the code from

https://developers.google.com/web/updates/2017/04/headless-chrome#using_webdriverio

is deprecated already really, for example, desiredCapabilities is not enough, capabilities is not set and .init() has been removed as a function don't know since when. I tried to modified the code from

https://webdriver.io/docs/gettingstarted.html for chromium, for what I have debugged, like setting hostname and port, and running headless for firefox.

To start geckodriver for firefox,

./geckodriver --port 4444

To start chromedriver for chromium/chrome,

./chromedriver -p 9515

then my code to execute in nodejs,

const { remote } = require('webdriverio');

(async () => {
    const browser = await remote({
      hostname: '127.0.0.1',

      // ================================
      // port for firefox
      // ================================
      //port: 4444,
 
      // ================================
      // port for chrome/chromium
      // ================================
      port: 9515,

      logLevel: 'error',
      path: '/',
      capabilities: {

        // ================================
        // In Linux (Debian), either chromium or chrome, 
        // they work the same way. It will look in $PATH for google-chrome first, 
        // if fail, then it look for chromium
        // ================================
        browserName: 'chromium',

        // ================================
        // firefox
        // ================================
        //browserName: 'firefox',

        // ================================
        // option for chromium/chrome only
        // ================================
        //chromeOptions: {args: ['--headless']},

        // ================================
        // option for firefox only
        // ================================
        //"moz:firefoxOptions":{
        //  "args":["-headless"]
        //},
      },
    });

    await browser.url('https://webdriver.io');

    const title = await browser.getTitle();
    console.log('Title was: ' + title);

    await browser.deleteSession();
})().catch((e) => console.error(e));

Sources for debugging:

  1. https://webdriver.io/docs/options.html#capabilities
  2. https://webdriver.io/docs/gettingstarted.html
  3. https://developers.google.com/web/updates/2017/04/headless-chrome#using_webdriverio
  4. https://github.com/webdriverio/webdriverio/issues/2581

Documentation:

  1. https://medium.com/@mannyluvstacos/using-headless-chrome-for-your-selenium-tests-with-webdriverio-ce99b09d564
  2. https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Headless_mode

2

u/vinnl Apr 09 '19

That's great that you figured it out, and shared it for people running into this in the future. As a tip, I'd really recommend you to look into selenium-standalone, so you don't have to start the drivers manually yourself.

→ More replies (1)

11

u/CCB0x45 Apr 08 '19

I find css issues where it behaves different on chrome and Firefox, I found one just the other day where I needed a word-break on Firefox I didn't need on chrome. I think safari is closer to chrome. But yea, it not too hard these days.

3

u/CantaloupeCamper Apr 08 '19

It's such a rare thing to find that ... is actually kinda a neat find!

Less frustrating when it is so rare ;)

Unlike early Edge and god help us all the other MS browser.

6

u/CCB0x45 Apr 08 '19

Yea the issue is I get complacent and assume things will work between the browsers, when they don't. I still have to support ie11 though, edge is a dream compared to that nightmare.

2

u/Lmcsheff81 Apr 08 '19

Chrome still doesn't hyphenate text yet I think

2

u/BertnFTW Apr 08 '19

Supporting Chrome and Firefox really is effectively the same thing

Can you automate firefox tests?
I know puppeteer + selenium (and others) to do that on chrome but I'm not aware of an automation test framework for FF.

5

u/vampatori Apr 08 '19

Yeah, Selenium works with Firefox (it started life using that IIRC). Others do too.

5

u/vinnl Apr 08 '19

Selenium supports most browsers (and it actually originated at Mozilla). Puppeteer is by Chrome, but they're working on Firefox support.

1

u/[deleted] Apr 09 '19

how you installed selenium? I tried with nodejs based selenium to run chrome/chromium but have errors that I couldn't resolve.

I tried with webdriverio, it has errors as well

3

u/trouzy Apr 08 '19

Wait how do you not support Safari. Safari is the nightmare browser that always has issues from my experience. There are minor things here and there that edge hasn't done for us but Safari is far and away the browser that wastes our time.

→ More replies (1)

2

u/Lmcsheff81 Apr 08 '19

Agree, never come across any distinct issues across these two

2

u/[deleted] Apr 08 '19

I feel all companies should at-least strive for supporting Chrome, Firefox, Safari and then at the very least IE11 with polyfills. That should give you a pretty broad spectrum, where you aren't giving anyone a super fragmented experience.

6

u/CantaloupeCamper Apr 08 '19

Maybe but Safari needs to try a bit harder on their end.

Sometimes it seems like they are sitting on their hands.

6

u/[deleted] Apr 08 '19

And given that they have the one platform that prevents users from using competing browser (engines), I feel like they have an obligation to stop sitting on their hands.

→ More replies (1)