gpt4 book ai didi

java - Selenium 选择和项目在 A "Div"

转载 作者:行者123 更新时间:2023-12-02 02:06:15 24 4
gpt4 key购买 nike

我是 Selenium 的新手,并且卡在“Div”、“UL”、“LI”、“class”中的项目选择上 ^^”

这是页面:(我想点击“Megaboss”): https://www.games-workshop.com/fr-FR/Warhammer?N=403739901+453061871&Nr=AND%28sku.siteId%3AFR_gw%2Cproduct.locale%3Afr_FR_gw%29&Nrs=collection%28%29%2Frecord%5Bproduct.startDate+%3C%3D+1564996500000+and+product.endDate+%3E%3D+1564996500000%5D

这是我的功能:

public void CliquerWarboss() {
find(By.xpath("//section[@id='mainContent']//a[text()='Megaboss']")).click();

}

我尝试通过 cssSelectorid 选择它,但似乎都不起作用。

这是问题消息:

11:26:37.451 [main] DEBUG n.t.c.steps.ConsoleLoggingListener - RELATED ISSUES: 
11:26:37.694 [main] ERROR n.t.c.steps.ConsoleLoggingListener - TEST FAILED AT STEP Cliquer warboss
11:26:37.695 [main] ERROR n.t.c.steps.ConsoleLoggingListener - element click intercepted: Element <a class="test-title-link-prod3140156 product-item__name" data-gtm-productfieldobject="{&quot;quantity&quot;:1,&quot;price&quot;:&quot;34.00&quot;,&quot;name&quot;:&quot;Ironjawz Orruk ...&quot;,&quot;id&quot;:&quot;99070209003&quot;,&quot;position&quot;:5,&quot;category&quot;:&quot;GW: Age of Sigmar&quot;}" data-gtm-actionfieldobject="{&quot;list&quot;:&quot;ResultsList | searchResults - Grand Alliance Destruction - Ironjawz&quot;}" href="/fr-FR/Ironjawz-Orruk-Megaboss">Megaboss</a> is not clickable at point (844, 640). Other element would receive the click: <img class="test-img-prod3140157" alt="Warchanter" src="https://www.games-workshop.com/resources/catalog/product/600x620/99070209004_Warchanter01.jpg">
11:26:37.717 [main] DEBUG n.t.core.reports.ReportService - Reporting formats: [JSON, HTML]

如果有人可以帮助我了解发生了什么? :/

谢谢

最佳答案

要确保可以单击这些元素,请使用WebDriverWait

WebDriverWait waitElmt = new WebDriverWait(driver, 60);
WebElement element = waitElmt.until(ExpectedConditions.elementToBeClickable(By.xpath("//section[@id='mainContent']//a[text()='Megaboss']")));
element.click();

关于java - Selenium 选择和项目在 A "Div",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57355712/

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