Giter Site home page Giter Site logo

puppeteer-selector's Issues

Cant find text inside a div

Hey! First of all thank you for this, i'm trying to use it in one of my projects and so far is working great.
But today i tried to find a div by the text inside of it (i can't use the id, the class or the name of the div), but it doesn't work.
What i tried is
await select(page).assertElementPresent('div:contains(Text) > "hello"');
const element = await select(page).getElement('div:contains(Text) > "hello"');
await element.click()

if you can help me with this it will be awesome.
Thank you

Sometimes selector contains does not found element

Step To Reproduce

Tell us about your environment:

  • Package.json:
    "puppeteer": "^1.17.0", "puppeteer-select": "^1.0.2"
  • Platform/OS: Ubuntu 18.04
  • Node Js version 8.14.0

What steps will reproduce the problem?

i have for loop, inside of it select element that contains text (pagination). Sometimes it cant find the element and throw error like this :
Error: an element with selector: "a.page_promo_lain:contains(undefined)" not found

my for loop code :
`for (let activePage of pages) {
console.log('page sekarang ' + activePage)
await page.waitFor(2000)

                let clickPage = await select(page).getElement(`a.page_promo_lain:contains(${activePage})`)
                await clickPage.click()
        
                // if promo exist
                if (await page.$('#imgClass') !== null) {
                    // get href promo
                    const hrefs = await page.evaluate(
                        () => Array.from(document.body.querySelectorAll('#promolain > li > a'), ({ href }) => href)
                    );

                    for (let href of hrefs) {
                        const detail = await getDetails(browser, href)
                        result[`${cat}`].push(detail);
                    }
                } else {
                    console.log('Promo not found!');
                }
            }`

What is the expected result?

should be able to click element

What happens instead?

cant find element

Sizzle is not defined

Unhandled promise rejection (rejection id: 1): Error: Evaluation failed: ReferenceError: Sizzle is not defined

Package.json:
"puppeteer": "^1.19.0", "puppeteer-select": "^1.0.3",
Platform/OS: Windows 10
Node Js version 8.9.1

const puppeteer = require('puppeteer');
const select = require ('puppeteer-select');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('somesite');
  
  await select(page).assertElementPresent('span:contains("someText")');
  const element = await select(page).getElement('span:contains("someText")');
  await element.click()

  await browser.close();
})();

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.