Untitled

mail@pastecode.io avatar
unknown
javascript
2 years ago
4.1 kB
11
Indexable
Never
const puppeteer=require('puppeteer')
const fs=require('fs/promises')

async function start(){
    const browser = await puppeteer.launch({
        headless: false,
    });

    const page =await browser.newPage()
    await page.goto("https://envista-arm.com", { waitUntil: 'networkidle0' })

    const BugReports=[]
    
    try {
        await page.waitForSelector("#mainMenuIcon").then(menu => menu.click());
        await page.waitForSelector("#mainMenu > li:nth-child(1) > span:nth-child(1)").then(menu => menu.click())
        await page.waitForSelector("#mainMenu > li > ul > li > span").then(menu => menu.click());
        await console.log(1);
        /*
        erorr 1
        */ 
          await page.waitForSelector("#mainMenu > li > ul > li > span").then(menu => menu.click());
    } 
    catch {
        await  page.screenshot({path: "menu.png", fullPage:true})
        BugReports.push("Error with menu, Need to double-click a span ")
      }

      //Checking  the first five stations
    for (let i = 0; i <=5; i++) {
        try {
          await page.waitForSelector("#stationsBox > ul > li:nth-child("+i+") > div > span.k-checkbox-wrapper > span").then(station => station.click());
        }catch{
        await  page.screenshot({path: "station.png", fullPage:true})
        BugReports.push("Error with selcet station ")}
    }
  try {
    await page.waitForNavigation("#selectReportPresentation > li:nth-child(2)").then(Graph => Graph.click());

    await page.waitForNavigation("#showResultsBtn").then(Display => Display.click());
    await page.waitForSelector("#reportsGraphImageIcon").then(GraphImag => GraphImag.click());
    await page.waitForSelector("#reportsExcelIcon").then(Excel => Excel.click());
    await page.waitForSelector("#reportsTableIcon").then(Table => Table.click());
    await page.waitForSelector("#report_result > div.k-window-titlebar.k-header.customHeader.reportResultPopupHeader > div.windowActionsContainer > img.popupExitIcon.popupWhiteExitIcon").then(Exit => Exit.click());

  }catch {
            await  page.screenshot({path: "Display_Table.png", fullPage:true})
            BugReports.push("Error with Display not show the result of Graph ")
          }

          
    try {
    await page.waitForNavigation("#showResultsBtn").then(Display => Display.click());
           /* erorr 2*/

    /*await page.waitForSelector("#reportsGraphImageIcon").then(GraphImag => GraphImag.click());
    await page.waitForSelector("#reportsExcelIcon").then(Excel => Excel.click());
    await page.waitForSelector("#reportsTableIcon").then(Table => Table.click());
    await page.waitForSelector("#report_result > div.k-window-titlebar.k-header.customHeader.reportResultPopupHeader > div.windowActionsContainer > img.popupExitIcon.popupWhiteExitIcon").then(Exit => Exit.click());

    */
    }catch (e) {
        if (e instanceof TimeoutError) {
        await  page.screenshot({path: "Display_Table.png", fullPage:true})
        BugReports.push("Error with Display not show the result of Table ")
      }}
    finally {
        console.log("sad");
    }

    




    try {
                
       /* erorr 3*/
        
        await page.waitForSelector("#checkboxBox").then(checkboxBox => checkboxBox.click(rect.x, rect.y, { clickCount: 2, delay: 2 }));

        console.log("SAdsad");
      }
      catch{
        await  page.screenshot({path: "dbclick.png", fullPage:true})
        BugReports.push("Error with dbclick label more then once ")

      }
      try {
                
        /* erorr 4*/
         
         await page.waitForSelector("#showResultBox > input.closeReportFormBtn.k-button").then(close => close.click());
 
       }
       catch{
         await  page.screenshot({path: "Cancel.png", fullPage:true})
         BugReports.push("Error with Cancel you can see imag Cancel.png")
 
       }
      
      
    await fs.writeFile("BugReports.txt",BugReports.join("\r\n"))
    await console.log('finish ');
    await browser.close
}

start()