WebdriverIO makes it very easy for you to run your tests on different browsers.
So right now, we have been using Chrome as our default browser.
We can easily change that to run Firefox by typing in “firefox”, right here for the
browserName in our wdio.conf.js file.
If we open our terminal and say,
npm test test, you see that it is running browser Firefox.
It opens up the Firefox browser, goes to the-internet.herokuapp.com. It ran the test and it passed.
So, that is how you can change from running Chrome to Firefox.
If you wanted to run Microsoft Edge, then you will do something similar.
You just change the
browserName to “MicrosoftEdge”.
And once again, we go in our terminal, and we say
Now ensure that you have the latest version of Microsoft Edge, Firefox, Chrome, or whatever browser you're trying to use, as sometimes you may get an error that it's just not working because of the browser version.
So here we see
It opens up Microsoft Edge and we are able to see our test passing in Microsoft Edge.
If you scroll back up, just take a look again, we see “capabilities > browserName: 'MicrosoftEdge'”, which is what we have here.
Now, if for some reason, your Microsoft Edge test fails and it's still not running, then I want you to follow the next set of instructions and hopefully they should get your Microsoft Edge running.
The first thing that we're going to do is download Microsoft Edge browser from microsoft.com/edge.
It has several options based on your operating system. I am downloading for Mac.
We're going to A_ccept and download_. Follow the instructions to install the browser. And if there are any updates that you need to do, do those.
We are then going to install the WebDriver for Microsoft edge, by going to developer.microsoft.com/microsoft-edge/tools/webdriver.
You need to know the browser version that you are using. This will help you to determine which Microsoft Edge driver you should download.
So, if you go into your About Microsoft Edge, you should see the version that you are using search for that version.
Download the driver based on your operating system.
Save the Microsoft Edge Driver to the root of your project.
In your config file, we are going to enter the browser details that we are going to be using to run our test.
In this case, it is “MicrosoftEdge”.
To run our test, we must first start the Microsoft Edge driver, and we do that by saying:
Open a new terminal and run your test.
For me, this normally takes a bit of time to start up. So, if you don't see it immediately opening, give it some time.
If it is that you followed those instructions and your test did not run, and you get an error, go back into your config file, remove
path, and move
path outside of your
capabilities, and re-run your test.