const puppeteer = require("puppeteer")
const expect = require("chai").expect

let browser;
let page;
let element;
let tag;

before(async () => {
    browser = await puppeteer.launch({
        timeout: 10000,
        headless: false
    });
    page = await browser.newPage();
})

after(() => {
    return browser.close()
})

describe("Session 34LALR5Id", function() {
    this.timeout(15000);
    it('Exploration 0', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.type(".hSrcInput > input", "écran plat");
        element = await page.evaluateHandle(() => document.activeElement);
        await element.asElement().press("Enter");


        await page.waitFor('#facetsList label');
        element = await page.$('#facetsList label');
        tag = await element.evaluate((elem) => elem.tagName);
        if (tag === 'SELECT') {
            await element.select('1')
        } else {
            await element.type('1')
        }
        await page.waitFor("input.btGreen.btS.jsValidForm");
        await page.click("input.btGreen.btS.jsValidForm");
        await page.waitFor(".btGreen.btF");
        await page.click(".btGreen.btF");

        await page.waitFor('div.bProductLineDescBottomQuantity.jsBProductLineDescBottomQuantity > select');
        element = await page.$('div.bProductLineDescBottomQuantity.jsBProductLineDescBottomQuantity > select');
        tag = await element.evaluate((elem) => elem.tagName);
        if (tag === 'SELECT') {
            await element.select('3')
        } else {
            await element.type('3')
        }

    });
    it('Exploration 1', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");

    });
    it('Exploration 2', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor("#hFull > div.hSearch > div.hSrcInput > button");
        await page.click("#hFull > div.hSearch > div.hSrcInput > button");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor("#hFull > div.hSearch > div.hSrcInput > button");
        await page.click("#hFull > div.hSearch > div.hSrcInput > button");

    });
    it('Exploration 3', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");

    });
    it('Exploration 4', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

    });
    it('Exploration 5', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

        await page.waitFor('#facetsList label');
        element = await page.$('#facetsList label');
        tag = await element.evaluate((elem) => elem.tagName);
        if (tag === 'SELECT') {
            await element.select('1')
        } else {
            await element.type('1')
        }

    });
    it('Exploration 6', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");
        await page.waitFor("input.btGreen.btS.jsValidForm");
        await page.click("input.btGreen.btS.jsValidForm");

    });
    it('Exploration 7', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");
        await page.waitFor("input.btGreen.btS.jsValidForm");
        await page.click("input.btGreen.btS.jsValidForm");

    });
    it('Exploration 8', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

    });
    it('Exploration 9', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

    });
    it('Exploration 10', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

    });
    it('Exploration 11', async () => {
        await page.goto("https://www.cdiscount.com/", {
            waitUntil: 'load'
        });
        await page.waitFor(".hSrcInput > input");
        await page.click(".hSrcInput > input");
        await page.waitFor(".hSrcComp > ul > li");
        await page.click(".hSrcComp > ul > li");

        await page.waitFor('#facetsList label');
        element = await page.$('#facetsList label');
        tag = await element.evaluate((elem) => elem.tagName);
        if (tag === 'SELECT') {
            await element.select('1')
        } else {
            await element.type('1')
        }
        await page.waitFor("div.prdtBILDetails > a");
        await page.click("div.prdtBILDetails > a");

    });
});