xPath:html/body/div [2]/ul/li [9]/a(ファイアパスを使用して生成)に続くリンクをクリックする必要があります。以下の通り:FirefoxDriverではコードは動作しますが、HtmlUnitDriverでは動作しません
HtmlUnitDriver driver= new HtmlUnitDriver(BrowserVersion.FIREFOX_3_6);
WebElement logoffElement = (new WebDriverWait(driver, 10))
.until(new ExpectedCondition<WebElement>(){
@Override
public WebElement apply(WebDriver d) {
return d.findElement(By.xpath("html/body/div[2]/ul/li[9]/a"));
}});
logoffElement.click();
上記のコードはFirefoxdriverのために働いていないが、HtmlUnitdriverにされています <のhref =>ログオフ
私のコードは次のようである "/ ABB /ログアウト"。 HtmlUnitdriverはエラー以下与える:
Caused by: org.openqa.selenium.NoSuchElementException: Unable to locate a node using html/body/div[2]/ul/li[9]/a
For documentation on this error, please visit: http://seleniumhq.org/exceptions/no_such_element.html
Build info: version: '2.21.0', revision: '16552', time: '2012-04-11 19:08:38'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_23'
Driver info: driver.version: HtmlUnitDriver
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElementByXPath(HtmlUnitDriver.java:802)
at org.openqa.selenium.By$ByXPath.findElement(By.java:344)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1244)
at org.openqa.selenium.htmlunit.HtmlUnitDriver$5.call(HtmlUnitDriver.java:1)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.implicitlyWaitFor(HtmlUnitDriver.java:984)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:1241)
at org.openqa.selenium.htmlunit.HtmlUnitDriver.findElement(HtmlUnitDriver.java:396)
at com.nike.automation.Task$1.apply(Task.java:70)
at com.nike.automation.Task$1.apply(Task.java:1)
at org.openqa.selenium.support.ui.FluentWait.until(FluentWait.java:201)
Java Scriptを有効にすると、私の問題が解決しました。しかし、新しいものに直面する "FailingHttpStatusCodeException - リダイレクトが多すぎる"、重要なステータスコード302のエラーをキャッチしています、それは意味がありますか? FirefoxDriverにはこのような問題はありませんが、HtmlUnitはそれに直面しています。私は失われた感じ...助けてください.. – Tirtha