2

私はちょっと新しい ですが、フレームにあるメニュー項目をHtmlUnit取得するのに問題があります。 以下のコードはFireFoxドライバーでは完全に正常に機能しますが、HtmlUnitDriverでは失敗します。"Setup"

   HtmlUnitDriver driver = new HtmlUnitDriver();
   driver.get(fleetWorkURL);

   WebElement usernameElement = driver.findElement(By.name("j_username"));
   usernameElement.sendKeys(username);

   WebElement passwordElement = driver.findElement(By.name("j_password"));
   passwordElement.sendKeys(password);

   WebElement logInButton = driver.findElement(By.className("button_acunia"));
   logInButton.click();

   driver.switchTo().frame("headerFrame");
   WebElement setupMenuItemElement = driver.findElement(By.id("setup"));
   setupMenuItemElement.click();

   // Check the title of the page, should be Fleet Works Setup
   System.out.println("Page title is: " + driver.getTitle());
   driver.close();

HtmlUnitドライバーの使用中にエラーが発生しました-

   Exception in thread "main" org.openqa.selenium.NoSuchFrameException: Unable to locate        frame with name or ID: headerFrame
  Build info: version: '2.28.0', revision: '18309', time: '2012-12-11 15:53:30'
 System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version:  '1.7.0_13'
 Driver info: driver.version: unknown
at org.openqa.selenium.htmlunit.HtmlUnitDriver$HtmlUnitTargetLocator.frame(HtmlUnitDriver.java:908)
at com.yukon.qasetup.xmlService.Example.main(Example.java:46)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

フレーム:

   <frameset border="0" rows="0,0,0,0,0,90,*" onunload="leave()"   onload="initMainWindow()">
<frame src="/fleet/html/empty.html" name="refreshTerminalsFrame" style="visibility: hidden; width: 0px; height: 0px; border: 0px;">
    <frame src="/fleet/html/empty.html" name="refreshDriversFrame" style="visibility: hidden; width: 0px; height: 0px; border: 0px;">
<frame src="/fleet/html/empty.html" name="refreshExternalDevicesFrame" style="visibility: hidden; width: 0px; height: 0px; border: 0px;">
<frame src="/fleet/html/empty.html" name="refreshUsersFrame" style="visibility: hidden; width: 0px; height: 0px; border: 0px;">
<frame src="/fleet/html/empty.html" name="refreshCustomersFrame" style="visibility: hidden; width: 0px; height: 0px; border: 0px;">
    <frame src="/fleet/jsp/header/headerFrame.jsp" name="headerFrame" frameborder="0" scrolling="no">   
    <frame src="/fleet/home.do" name="displayFrame" frameborder="0" scrolling="yes">
     </frameset>
4

1 に答える 1