I need help in accessing the li elements in the below link.
https://www.healthdirect.gov.au/medicines/brand/amt,934621000168103/l-arginine-rch
My li elements under document.querySelectorAll('#disclaimer+section li')
I tried,
const seeAlsoElements = Selector( () => {
const seeA = document.querySelectorAll('#disclaimer+section li');
return seeA;
});
const seeAlso = await seeAlsoElements();
actualSeeAlsoFirstLine = seeAlso[0].innerText().split(':');
aSADAlink = seeAlsoElements[1].child('a').getAttribute('href');
genericVsBrandArticle = seeAlsoElements[2].getAttribute('href');
but I am getting errors. Please help me in correcting this code. I need to individually access the li tags for their href or inner text;
Your code should look like this:
const seeAlsoItems = Selector('main')
.find('footer')
.find('section')
.find('h2').withText('See also')
.sibling('ul')
.find('li');
const arginineLink = seeAlsoItems.nth(0).find('a');
await t
.expect(arginineLink.getAttribute('href'))
.eql('https://www.healthdirect.../arginine', {timeout: 10000});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With