testproject-io / javascript-opensdk

TestProject OpenSDK for Node.js
Apache License 2.0
24 stars 16 forks source link

WebDriverError using chrome testing expedia #33

Open ShaharGilad opened 3 years ago

ShaharGilad commented 3 years ago

Running the following code 5 times with test-project Builder and it failed 4 of 5 times with WebDriverError. Running the same code with Selenium Builder passed the test.

const { By, Key } = require('selenium-webdriver');
const { Builder } = require('@tpio/javascript-opensdk');
const { assert } = require('chai');

const CONSTANT = {
    TOKEN: 'TOKEN'
};

describe('Chrome expedia test', ()=> {
    let driver;

    before(async ()=>{
        driver = await new Builder().forBrowser('chrome').withToken(CONSTANT.TOKEN).build();
    });

    after(async()=>{
        await driver.quit();
    });

    it('Search NYC', async () =>{
        await driver.get('https://www.expedia.com/');

        const goingToButton = await driver.findElement(By.xpath("//button[contains(@data-stid, 'location-field-destination-menu-trigger')]"));
        await goingToButton.click();
        const goingToInput = await driver.findElement(By.id('location-field-destination'));
        await goingToInput.sendKeys('NYC');
        await goingToInput.sendKeys(Key.ENTER);

        const checkInButton = await driver.findElement(By.id("d1-btn"));
        await checkInButton.click();

        const dateIn = await driver.findElement(By.xpath("//button[contains(@data-day, '7')]"));
        await dateIn.click();

        const dateOut = await driver.findElement(By.xpath("//button[contains(@data-day, '10')]"));
        await dateOut.click();
        await driver.findElement(By.xpath("//button[contains(@data-stid, 'apply-date-picker')]")).click();

        await driver.findElement(By.id('adaptive-menu')).click();

        await driver.findElement(By.xpath("//button[contains(@data-testid, 'add-room-button')]")).click();
        await driver.findElement(By.xpath("//button[contains(@data-testid, 'guests-done-button')]")).click();

        await driver.findElement(By.xpath("//button[contains(@data-testid, 'submit-button')]")).click();

        const inputText = await driver.findElement(By.xpath("//button[contains(@data-stid, 'hotels-destination-menu-trigger')]")).getText();
        assert.equal(inputText, 'New York, NY, United States of America (NYC-All Airports)');

        await driver.findElement(By.xpath("//label[contains(@for, 'lodging-0-HOTEL')]")).click();

        const roomElement = await driver.findElement(By.xpath("//a[contains(@data-stid, 'open-hotel-information')]"));
        const url = await roomElement.getAttribute('href');

        await driver.get(url);
    });
});

The error:

image