我想從列表中選擇一個(gè)DropDown,但是HTML沒(méi)有選擇標(biāo)簽,我不確定我應(yīng)該使用Select類(lèi)還是其他類(lèi)
要選擇從一個(gè)值DropDown,你必須先 在WebElement ,然后選擇 您可以使用下面的代碼塊:
WebElement elem = driver.findElement(By.xpath('//a[@id=’highlight-addons’]'));Actions action = new Actions(driver);action.movetoElement(elem).perform();List<WebElement> items = driver.findElements(By.xpath('//ul[@class=’add-ons-tab’]/li/a'));for(WebElement myitem:items){ if(myitem.getAttribute('innerHTML').contains('Membership')) {myitem.click();break; }}解決方法
我是selenium的新手,我想執(zhí)行一個(gè)簡(jiǎn)單的任務(wù),我想從選項(xiàng)卡中選擇一個(gè)下拉菜單,并且我已使用“http://www.spicejet.com/”作為參考。網(wǎng)頁(yè)spicejet.com中有一個(gè)“附加”標(biāo)簽,其中包含“下拉”值,我想從列表中選擇任意一個(gè)值。HTML代碼沒(méi)有select標(biāo)記,因此Select類(lèi)沒(méi)有給我適當(dāng)?shù)慕Y(jié)果。
這是HTML代碼:
<a href='javascript:void(0);' class=''>Add-Ons<span class='rightarrowclass'> </span><span class='rightarrowclass'> </span></a><li><a href='http://www.aoyou183.cn/wenda/SpiceClubMembershipOffer.aspx'>SpiceClub Membership Offer</a></li><li id='ctl00_lblSpiceClublink'><a href=’javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions('ctl00$lblSpiceClub','',false,'SpiceClub.aspx',true))’>SpiceCash/SpiceClub</a></li><li><a >SpiceCash Topup </a></li><a >SpiceMax </a>
請(qǐng)幫助我,讓我知道如何前進(jìn)。
相關(guān)文章:
