如何在給定頁面上獲取連衣裙類別的 xpath(帶有連衣裙文本的影像)
https://www.amazon.com/b/ref=af_spr22_L1_w_nav_1?pf_rd_r=5FE3DS056G2PHQZPGCQV&pf_rd_p=e8199fbf-0485-4dda-aa8b-cc7a20b4c115&pf_rd_m=ATVPDKIKX0DER&pf_rd_s=merchandised-search-6&pf_rd_t=30901&pf_rd_i=7147440011&node=1040660
我試過這個: Actions action = new Actions(driver);
WebElement 衣服樣式 = driver.findElement(By.xpath("//span[@data-csa-c-id='8nt4i-t93vdn-vkyjb-b2c2aj']")); action.moveToElement(clothestyle).build().perform();
但是 NoSuchElementException 即將到來
uj5u.com熱心網友回復:
嘗試找到更簡單的 Xpath,你的似乎是基于自動生成的資料,所以很快就會過期。嘗試類似:
//img[@alt='Dresses']/../../parent::a
或者
//img[@alt='Dresses']/parent::div
此外,如果您只需要打開部分,單擊元素就足夠了:
WebElement clothestyle = driver.findElement(By.xpath("//img[@alt='Dresses']/../../parent::a"));
clothestyle.click();
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/465595.html
標籤:爪哇 硒网络驱动程序 硒铬驱动程序 鼠标事件 鼠标移到
上一篇:在ASP.NET專案中在哪里可以找到或添加_AppStart和_PageStart?
下一篇:SeleniumJava4.1.3java.lang.NoClassDefFoundError:org/openqa/selenium/WebDriver
