-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Recipe for using AVA with Selenium #1023
Comments
This is quite straight forward: import test from 'ava';
let webdriverio = require('webdriverio');
let client = webdriverio.remote({
// just using a local chromedriver
desiredCapabilities: {browserName: 'chrome'}
});
test.before(async t => {
await client.init()
.url('http://localhost');
});
test.after.always(async t => {
await client.end();
});
test('has a body', t => {
return client.isExisting('body').then(result => {
t.true(result);
});
}); I've only had success using AVA and webdriverio together when running tests serially |
@rhubarbselleven Interested in submitting a recipe? |
I did have success running tests in parallel with selenium-webdriver package. Here is my example code: import test from 'ava';
import webdriver from 'selenium-webdriver';
test.beforeEach(t => {
t.context.driver = new webdriver.Builder()
.forBrowser('chrome')
.usingServer('http://localhost:4444/wd/hub')
.build();
});
test('Search for webdriver', async t => {
let driver = t.context.driver;
await searchGoogle(driver, 'webdriver')
t.is(await driver.getTitle(), "webdriver - Google Search");
await driver.quit();
});
test('Search for avajs', async t => {
let driver = t.context.driver;
await searchGoogle(driver, 'avajs')
t.is(await driver.getTitle(), "avajs - Google Search");
await driver.quit();
});
test('Search for concurrent', async t => {
let driver = t.context.driver;
await searchGoogle(driver, 'concurrent')
t.is(await driver.getTitle(), "concurrent - Google Search");
await driver.quit();
});
async function searchGoogle(driver, keyword) {
await driver.get('http://www.google.com/ncr');
await driver.findElement(webdriver.By.name('q')).sendKeys(keyword);
await driver.findElement(webdriver.By.name('btnG')).click();
await driver.wait(webdriver.until.titleIs(keyword + ' - Google Search'), 1000);
} |
@nreijmersdal After running the above code, the tests are getting executed serially. Getting the below results with 'ava --verbose' √ Search for webdriver (6.6s) I'm running [email protected], [email protected] and [email protected] which uses selenium-server-standalone-3.5.3.jar. Any ideas what change is now required to get the tests running in parallel? |
@aptester Sorry no idea. Also I am not using Ava anymore. Running each test in parallel doesn't make a lot of sense anyways. Maybe it is easier to group sets of tests and create a couple of command-line jobs to start the groups in parallel. This is what I used to do when we used Java for Selenium. Goodluck. |
It's a common need. We should have a recipe to make it easy for users to get started.
I think Webdriver.IO would be the best choice.
The text was updated successfully, but these errors were encountered: