gpt4 book ai didi

testing - testcafe 访问 li 元素

转载 作者:行者123 更新时间:2023-12-05 03:03:42 25 4
gpt4 key购买 nike

我需要帮助访问以下链接中的 li 元素。

https://www.healthdirect.gov.au/medicines/brand/amt,934621000168103/l-arginine-rch

我的 li 元素在 document.querySelectorAll('#disclaimer+section li') 下

我试过了,

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');

但我收到错误。请帮助我更正此代码。我需要单独访问其 href 或内部文本的 li 标签;

最佳答案

您的代码应如下所示:

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});

关于testing - testcafe 访问 li 元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53626409/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com