testproject-io / javascript-opensdk

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

WebDriverError: when using edge testing expedia #34

Open ShaharGilad opened 3 years ago

ShaharGilad commented 3 years ago

Running the following code 5 times, 3 times failed with WebDriverError, and 2 more passed.

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('MicrosoftEdge').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);

        const headerDisplayed = await driver.findElement(By.xpath("//h1[contains(@class , 'uitk-heading-3')]")).isDisplayed();
        assert.equal(headerDisplayed, true);

        await driver.report().step('Take a picture of expedia room', 'Snapshoot of expidea room', true);
    });
});

The error:

image