您的位置:首页技术文章
文章详情页

我想从列表中选择一个DropDown,但是HTML没有选择标签,我不确定我应该使用Select类还是其他类。

【字号: 日期:2024-04-22 11:13:26浏览:75作者:猪猪
如何解决我想从列表中选择一个DropDown,但是HTML没有选择标签,我不确定我应该使用Select类还是其他类。?

要选择从一个值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的新手,我想执行一个简单的任务,我想从选项卡中选择一个下拉菜单,并且我已使用“http://www.spicejet.com/”作为参考。网页spicejet.com中有一个“附加”标签,其中包含“下拉”值,我想从列表中选择任意一个值。HTML代码没有select标记,因此Select类没有给我适当的结果。

这是HTML代码:

<a href='javascript:void(0);' class=''>Add-Ons<span class='rightarrowclass'>&nbsp;</span><span class='rightarrowclass'>&nbsp;</span></a><li><a href='https://www.haobala.com/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 href='http://book.spicejet.com/SpiceMoneyTopup.aspx'>SpiceCash Topup </a></li><a href='http://book.spicejet.com/RetrieveBooking.aspx?AddSeat=true'>SpiceMax </a>

请帮助我,让我知道如何前进。

标签: HTML
相关文章: