Closed alpriya87 closed 4 years ago
I'm a little surprised what you've done in helper.js doesn't work I'll try to find some time later next week to look at this. I want to make using the this lib with puppeteer better, you may have seen the updates to introduce playwright support which is done I a much nicer way I'd like to do that same with puppeteer if it supported it
Great, looking forward for the update on this!! will be much useful for my current project.
One thing to check with your code example you are importing path but also have function named path in the same scope, this wont work
also you re not passing in the page object?
I'm passing it in the page object
Georgegriff, i do not have any other function named path.
I also see that few click and tags are not recognized with deepqueryselector for ex: below is the complete path document.querySelector("body > web").shadowRoot.querySelector("search").shadowRoot.querySelector("#search > div.search-text > dn-search").shadowRoot.querySelector("#helpers-1234").shadowRoot.querySelector("div > span")
deep selector to get the inner text is not working in this case
Happy to look into if there are issues with the library, what are those web
and search
elements? Can't be web components they have no dash
Doesn't seem valid that an element of web
can be a direct child of body
which is what your above snippet suggests, I'm not aware of an element called web?
Georgegriff, i do not have any other function named path.
What I meant was your function is named path and you're using the path node module path.join...
, this doesn't seem right, please look closer at my screenshot
Closing due to inactivity
Hi,
At present I have multiple test cases in a single file and i end up defining the library for each case.
Can you please show us some example of how to reference the library from a different file to use it inside the actual code. Probably a function
I'm new to javascript. This would definitely help a lot to most I believe!!
await this.page.addScriptTag({ path: path.join(__dirname, '../../node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js') });
Reference the above code in the actual test case.
I tried to use it from different file like below :
helper.js async function path() { await this.page.addScriptTag({ path: path.join(__dirname, '../../../node_modules/query-selector-shadow-dom/dist/querySelectorShadowDom.js') }); } module.exports = { path };
code : const pathFor = require('./lib/helper.js')
await pathFor.path(); // this is the code in question
try { const nextbtn = (await this.page.waitForFunction(() => { const nextbtn = querySelectorShadowDom.querySelectorDeep(".something") return nextbtn; })).asElement(); await nextbtn.click(); console.log("clicking the button is a success")
Thanks in advance