我需要從下拉選擇一個值,其中有JavaScript。任何幫助,高度讚賞!下拉選擇自動化使用硒的JavaScript
以下HTML:
<div class="popupMenuButton">
<a id="_sawrl" bh="PML" _mid="_g7yog" class="awmenuLink" style="text-decoration:none" href="#">
<nobr>
FORMALIN VAPO TABS
<img width="15" height="17" align="absmiddle" border="0" style="margin-bottom:1px;" src="/EasyCare-2.0/AribaWeb/ad/content/AWXDebugResourceActions/13/en_US/widg/arrowcolor.gif" alt="">
</nobr>
</a>
</div>
Java代碼
WebElement dropDownListBox = waitById("_sawrl");
Select clickThis = new Select(dropDownListBox);
clickThis.selectByVisibleText("FORMALIN VAPO TABS")
異常
Exception in thread "main" org.openqa.selenium.support.ui.UnexpectedTagNameException: Element should have been "select" but was "a"
Build info: version: '2.42.2', revision: '6a6995d', time: '2014-06-03 17:42:30'
System info: host: , os.name: 'Windows 8', os.arch: 'x86', os.version: '6.2', java.version: '1.7.0_51'
Driver info: driver.version: unknown
at org.openqa.selenium.support.ui.Select.<init>(Select.java:46)
at ui.stores.UIMaterialRecepit.setBrandName(UIMaterialRecepit.java:71)
at tc.stores.TCMaterialRecepit.receiveMaterial(TCMaterialRecepit.java:32)
at tc.StartAutmation.main(StartAutmation.java:48)
謝謝你的答覆。你可以請添加一些硒代碼? – sudhir 2014-10-17 07:06:46
我對硒一無所知。我只是在這裏解釋錯誤。 – Cerbrus 2014-10-17 07:07:17
是否有可能看到網站的行爲?或者你可以形容它? 正如Cerbrus所提到的,「new Select()」只接受