Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get values from the iframe ? #61

Open
collegepinger opened this issue Aug 11, 2017 · 2 comments
Open

How to get values from the iframe ? #61

collegepinger opened this issue Aug 11, 2017 · 2 comments

Comments

@collegepinger
Copy link

collegepinger commented Aug 11, 2017

How to get whole document body value which is inside iframe But it returns me nothing

const HeadlessChrome = require('simple-headless-chrome');

const browser = new HeadlessChrome({
    headless: false // If you turn this off, you can actually see the browser navigate with your instructions
    // see above if using remote interface
});

async function navigateWebsite() {
    try{
        await browser.init()

        const mainTab = await browser.newTab({ privateTab: false })

        await mainTab.goTo('http://someSiteIframe.com');

        let frames = await mainTab.getFrames()
        await mainTab.wait(2000);

        let sampleId = frames[1].id;

        console.log(sampleId)

        mainTab.getValue('document.body',`${sampleId}`).then(data => {
            console.log(data,sampleId,"From frame")
        });

        const htmlTag = await mainTab.evaluate(function(selector) {
            return document.querySelector(selector)

        }, '.slave-0-1');



        await browser.close()

    }catch (err){
        console.log('ERROR!', err)
    }
}

navigateWebsite()
@LucianoGanga
Copy link
Owner

Hi @collegepinger !

Sorry for the late reply. Can you give me the URL of the site you're trying to get the value from?

So I can help you with the code.

Thanks!
Lucho

@LucianoGanga
Copy link
Owner

Hi @collegepinger !

Could you fix the issue?

Thanks!
Luciano

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants