added pagination
							parent
							
								
									ab47acc4f0
								
							
						
					
					
						commit
						11962a3ff3
					
				| 
						 | 
					@ -56,7 +56,7 @@ const utils = require("./utils");
 | 
				
			||||||
    utils.getBrowserConfig(chromeProfilePath, environment)
 | 
					    utils.getBrowserConfig(chromeProfilePath, environment)
 | 
				
			||||||
  );
 | 
					  );
 | 
				
			||||||
  const page = await browser.newPage();
 | 
					  const page = await browser.newPage();
 | 
				
			||||||
 // await loadPageCookies(page);
 | 
					  // await loadPageCookies(page);
 | 
				
			||||||
  await page.setViewport({
 | 
					  await page.setViewport({
 | 
				
			||||||
    width: 1600,
 | 
					    width: 1600,
 | 
				
			||||||
    height: 900,
 | 
					    height: 900,
 | 
				
			||||||
| 
						 | 
					@ -129,10 +129,26 @@ const utils = require("./utils");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  // orders array
 | 
					  // orders array
 | 
				
			||||||
  let orders_list = [];
 | 
					  let orders_list = [];
 | 
				
			||||||
  const pagination = 10;
 | 
					  const pagination = 100;
 | 
				
			||||||
  let total_items = 0;
 | 
					  let total_items = 0;
 | 
				
			||||||
  let currentPage = 1;
 | 
					  let currentPage = 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  await new Promise((resolve) => setTimeout(resolve, 2_000));
 | 
				
			||||||
 | 
					  // set the pagination to 100 / page
 | 
				
			||||||
 | 
					  const pageinationSeletor =
 | 
				
			||||||
 | 
					    "#orders-tab-list > div.y0DVv7GO > div > div._38NAUUfN > div._15QWqbZs > ul > li.PGT_sizeChanger_123 > div > div > div > div > div";
 | 
				
			||||||
 | 
					  await page.waitForSelector(pageinationSeletor);
 | 
				
			||||||
 | 
					  await page.click(pageinationSeletor);
 | 
				
			||||||
 | 
					  console.log("Clicking on pagination Select");
 | 
				
			||||||
 | 
					  await new Promise((resolve) => setTimeout(resolve, 3_000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  // select 100 /page option
 | 
				
			||||||
 | 
					  const pagesPerPageSelector =
 | 
				
			||||||
 | 
					    "body > div.PT_outerWrapper_123.PP_outerWrapper_123.ST_dropdown_123.ST_mediumDropdown_123.PT_dropdown_123.PT_portalTopLeft_123.PT_inCustom_123.PP_dropdown_123 > div > div > div > div > ul > li:nth-child(5)";
 | 
				
			||||||
 | 
					  await page.waitForSelector(pagesPerPageSelector);
 | 
				
			||||||
 | 
					  await page.click(pagesPerPageSelector);
 | 
				
			||||||
 | 
					  await new Promise((resolve) => setTimeout(resolve, 1_000));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if (orders_list.length === 0) {
 | 
					  if (orders_list.length === 0) {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
      // get total items
 | 
					      // get total items
 | 
				
			||||||
| 
						 | 
					@ -354,7 +370,7 @@ const utils = require("./utils");
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      // get orders with 1 item with quantity 1
 | 
					      // get orders with 1 item with quantity 1
 | 
				
			||||||
      console.log( `Item Quantity : ${itemElements.length}`)
 | 
					      console.log(`Item Quantity : ${itemElements.length}`);
 | 
				
			||||||
      if (itemElements.length > 1) {
 | 
					      if (itemElements.length > 1) {
 | 
				
			||||||
        console.log(`${order} : has more then 1 item`);
 | 
					        console.log(`${order} : has more then 1 item`);
 | 
				
			||||||
        return;
 | 
					        return;
 | 
				
			||||||
| 
						 | 
					@ -384,7 +400,7 @@ const utils = require("./utils");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // check quantity should be 1 as well
 | 
					        // check quantity should be 1 as well
 | 
				
			||||||
        if (parseInt(quantity) > 1) {
 | 
					        if (parseInt(quantity) > 1) {
 | 
				
			||||||
          console.log("Item has more than quantity")
 | 
					          console.log("Item has more than quantity");
 | 
				
			||||||
          return;
 | 
					          return;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue