我無法在IE瀏覽器中使用Selenium Web驅動程序單擊單選按鈕。無法點擊單選按鈕Internet Explorer
的HTML如下:
<TD class=PlainText>
<INPUT onclick="javascript: ShowHideInvoicePanel();setTimeout('__doPostBack(\'ctl00$cphClaimFlow$tabcontainerClaimFlow$tabFulfillment$Shipping$rdoYesFindMyPhone\',\'\')', 0)" id=ctl00_cphClaimFlow_tabcontainerClaimFlow_tabFulfillment_Shipping_rdoYesFindMyPhone type=radio value=rdoYesFindMyPhone name=ctl00$cphClaimFlow$tabcontainerClaimFlow$tabFulfillment$Shipping$phoneanswer>
<LABEL for=ctl00_cphClaimFlow_tabcontainerClaimFlow_tabFulfillment_Shipping_rdoYesFindMyPhone>Yes</LABEL>
<INPUT onclick="javascript: ShowHideInvoicePanel();setTimeout('__doPostBack(\'ctl00$cphClaimFlow$tabcontainerClaimFlow$tabFulfillment$Shipping$rdoNoFindMyPhone\',\'\')', 0)" id=ctl00_cphClaimFlow_tabcontainerClaimFlow_tabFulfillment_Shipping_rdoNoFindMyPhone type=radio value=rdoNoFindMyPhone name=ctl00$cphClaimFlow$tabcontainerClaimFlow$tabFulfillment$Shipping$phoneanswer>
<LABEL for=ctl00_cphClaimFlow_tabcontainerClaimFlow_tabFulfillment_Shipping_rdoNoFindMyPhone>No</LABEL>
下面是我的代碼:要顯示
WebDriverWait waitForErasePhnYesRadio=new WebDriverWait(driver, timeOut);
WebElement elementErasePhnYesRadio= waitForErasePhnYesRadio.until(ExpectedConditions.elementToBeClickable(By.id("ctl00_cphClaimFlow_tabcontainerClaimFlow_tabFulfillment_Shipping_rdoYesFindMyPhone")));
elementErasePhnYesRadio.click();
logger.info("Clicked on Yes button of erase phone script");
if(elementErasePhnYesRadio.isSelected()==false){
System.out.println("is radio btn selected 1 : "+elementErasePhnYesRadio.isSelected());
elementErasePhnYesRadio.click();
System.out.println("is radio btn selected 2 : "+elementErasePhnYesRadio.isSelected());
}
System.out.println("is radio btn selected 3 : "+elementErasePhnYesRadio.isSelected());
我已經加入等待語句,因爲我在等待來回單選按鈕。代碼正在執行,不會顯示錯誤或異常。
以下輸出顯示控制檯:
INFO [main] (ShippingPage.java:45) - Clicked on Yes button of erase phone script
is radio btn selected 1 : false
is radio btn selected 2 : false
is radio btn selected 3 : false
它爲我工作......謝謝:D –