Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

Puppeteer selector cannot find the correct element into the iframe

$
0
0

I am trying to make work a selector to click on the 'search' button, I have already typed in the input but still without success to click on the 'search' button, it should be noted that the form is inside a iframe.

Here is my code

const puppeteer = require("puppeteer-extra");const StealthPlugin = require("puppeteer-extra-plugin-stealth");const url = "https://www.mercadopublico.cl/Home";async function openWebPage() {  puppeteer.use(StealthPlugin());  const browser = await puppeteer.launch({    timeout: 70000,    headless: false,    executablePath: "C:/Program Files/Google/Chrome/Application/chrome.exe",    userDataDir: "C:/Users/javsiv7/AppData/Local/Google/Chrome/User Data",  });  const page = await browser.newPage();  await page.goto(url, { timeout: 70000 });  await page.waitForSelector('button.btn.btn-xl.btn-pri', { timeout: 70000 });  await page.click('button.btn.btn-xl.btn-pri', { timeout: 70000 });  await page.waitForSelector('#zocial-oidc', { timeout: 70000 });  await page.click('#zocial-oidc', {timeout :70000 });  // write username and password  await page.waitForSelector("#uname", { timeout: 70000 });  await page.type("#uname", "27.063.931-3");  await page.waitForSelector("#pword", { timeout: 70000 });  await page.type("#pword", "Meryi.15");  // click login  await page.waitForSelector("#login-submit", { timeout: 70000 });  await page.click("#login-submit");  await page.waitForNavigation({timeout: 70000});  await page.waitForSelector('#rdbOrg1820428', { timeout: 70000 });  await page.click('#rdbOrg1820428');  await page.waitForSelector('a.btn.btn-pri', { timeout: 70000 });  await page.click('a.btn.btn-pri', {timeout: 70000});  await page.waitForNavigation({timeout: 70000});  await page.click('#mnuPrincipaln3 .mnuPrincipal_1', {timeout: 70000});  const elementHandle = await page.waitForSelector('#fraDetalle');  const frame = await elementHandle.contentFrame();  await frame.waitForSelector('.MuiInputBase-input', { timeout: 70000 });  await frame.type('.MuiInputBase-input', '900-127-COT24');  await frame.waitForSelector('button.MuiButtonBase-root.Buttonstyles__BaseButton-sc-1r23i1a-2.Buttonstyles__ContainedButton-sc-1r23i1a-3.exhqeh.ktEJEN.QuoteSearchHeadingFiltersstyles__SearchButton-sc-475dvi-1.bPKlqW[color="primary"][type="submit"]', { timeout: 70000, visible: true });  await frame.click('button.MuiButtonBase-root.Buttonstyles__BaseButton-sc-1r23i1a-2.Buttonstyles__ContainedButton-sc-1r23i1a-3.exhqeh.ktEJEN.QuoteSearchHeadingFiltersstyles__SearchButton-sc-475dvi-1.bPKlqW[color="primary"][type="submit"]');}openWebPage();

exactly on this line of code is where it stops working:

await frame.click('button.MuiButtonBase-root.Buttonstyles__BaseButton-sc-1r23i1a-2.Buttonstyles__ContainedButton-sc-1r23i1a-3.exhqeh.ktEJEN.QuoteSearchHeadingFiltersstyles__SearchButton-sc-475dvi-1.bPKlqW[color="primary"][type="submit"]');

Viewing all articles
Browse latest Browse all 12111

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>