以下は、 http: //www.royalmailgroup.com/ のホームページ用に作成されたクラスです 。About us リンクと FOI 連絡先をクリックしようとしています。
package sample.keyword;
import java.io.File;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.internal.Coordinates;
import org.openqa.selenium.internal.Locatable;
import org.openqa.selenium.support.events.EventFiringWebDriver;
import org.openqa.selenium.support.events.internal.EventFiringMouse;
public class FeeToPay {
public static WebElement Menu, SubMenu ;
public static InternetExplorerDriver driver;
//public static FirefoxDriver driver;
public static EventFiringWebDriver eDriver;
public static EventFiringMouse eMouse;
public static String xpathMainMenu ="//div[@class='content']/ul/li/span/*";
public void OpenApplication(String Url) throws Exception{
File file = new File("D:\\Software\\IEDriverServer.exe");
System.setProperty("webdriver.ie.driver", file.getAbsolutePath());
driver= new InternetExplorerDriver();
//driver = new FirefoxDriver();
eDriver= new EventFiringWebDriver(driver);
eMouse= new EventFiringMouse(eDriver, null);
driver.manage().window().maximize();
try{
String baseUrl = "http://www.royalmailgroup.com/";
this.driver.get(baseUrl);
}
catch(Exception E){
throw E;
}
}
public static EventFiringWebDriver getWebDriver(){
return eDriver;
}
public void NavigateTo(String strMenuPath) throws Exception {
if(strMenuPath == null || strMenuPath.isEmpty())throw new Exception("no menu path mentioned");
String [] MenuItems = strMenuPath.split("->");
java.util.List<WebElement> liMenuItems;
liMenuItems= FeeToPay.getWebDriver().findElements(By.xpath(xpathMainMenu));
for (int counter =0; counter<MenuItems.length;counter++ ){
if(counter==0){
if(liMenuItems.get(counter).getText().equalsIgnoreCase(MenuItems[counter])){
Locatable item = (Locatable)liMenuItems.get(counter);
Coordinates c = item.getCoordinates();
eMouse.mouseMove(c);
}
}
if(counter!=0 && counter == MenuItems.length-1 ){
eDriver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement ele = eDriver.findElement(By.linkText(MenuItems[counter]));
ele.click();
}
}
} }
エラー [VerboseTestNG] FAILED: "sample.keyword.FeeToPayTest" - sample.keyword.FeeToPayTest.testOpenApplication() が 9033 ミリ秒で終了しました [VerboseTestNG] org.openqa.selenium.ElementNotVisibleException: The point at the point at the driver is attempts要素をクリックしても、ビューポートにスクロールされませんでした。(警告: サーバーはスタックトレース情報を提供しませんでした) [VerboseTestNG] コマンドの所要時間またはタイムアウト: 1.93 秒
Selenium Jar ビルド情報を使用しています: バージョン: '2.28.0'、リビジョン: '18309'、システム情報: os.name: 'Windows 7'、os.arch: 'amd64'、os.version: '6.1'、 java.version: '1.6.0_37'