2

Windows XP で最新の Selenium コード、2.25 IEDriver 2.25.2 32 ビット、IE 8 32 ビットを使用しています。以下の簡単なコード リストを使用すると、「見つかった要素!!」にたどり着きません。InternetExplorerDriver を使用する場合の行。ページを開き、ページ タイトルを読み取りますが、findElement 呼び出しで失敗します。FirefoxDriver に交換すると動作します。ハブを介して IE 9 64 ビットをリモート PC で動作させることができました (最初の 2 行のコメントを外し、WebDriver の 2 行をコメント アウトします)。

これが IE 32 ビットで失敗する理由がわかりません。

===========================================

package com.company.test;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

public class App 
{
    public static void main( String[] args ) throws InterruptedException, MalformedURLException
    {
        // Grid driver
//        DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
//        WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);

        // Local driver
//        WebDriver driver = new FirefoxDriver();

        WebDriver driver = new InternetExplorerDriver();
        try {
            driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
            driver.get("http://seleniumhq.org/");
            String pageTitle = driver.getTitle();
            System.out.println("pageTitle=" + pageTitle);
            driver.findElement(By.id("q")).clear();
            System.out.println("Found element!!");
            driver.findElement(By.id("q")).sendKeys("test");
            driver.findElement(By.id("submit")).click();
        } finally {
            driver.quit();
        }
        System.out.println("Done");
    }
}

================================================== ==========

IEDriver を取得して TRACE ログを生成することができました。関心のあるスニペットは次のとおりです。

T 2012-08-09 16:04:09:516 IECommandExecutor.cpp(604) Entering IECommandExecutor::LocateElement
T 2012-08-09 16:04:09:516 IECommandExecutor.cpp(587) Entering IECommandExecutor::GetElementFindMethod
T 2012-08-09 16:04:09:516 ElementFinder.cpp(33) Entering ElmentFinder::FindElement
T 2012-08-09 16:04:09:516 IECommandExecutor.cpp(439) Entering IECommandExecutor::GetCurrentBrowser
T 2012-08-09 16:04:09:516 IECommandExecutor.cpp(445) Entering IECommandExecutor::GetManagedBrowser
T 2012-08-09 16:04:09:516 ElementFinder.cpp(468) Entering ElementFinder::SanitizeCriteria
T 2012-08-09 16:04:09:516 ElementFinder.cpp(479) Entering ElementFinder::ReplaceAllSubstrings
T 2012-08-09 16:04:09:516 ElementFinder.cpp(479) Entering ElementFinder::ReplaceAllSubstrings
T 2012-08-09 16:04:09:516 Browser.cpp(91) Entering Browser::GetDocument
I 2012-08-09 16:04:09:516 Browser.cpp(95) No child frame focus. Focus is on top-level frame
T 2012-08-09 16:04:09:516 IECommandExecutor.cpp(187) Entering IECommandExecutor::OnGetResponseLength
T 2012-08-09 16:04:09:532 IECommandExecutor.cpp(187) Entering IECommandExecutor::OnGetResponseLength
T 2012-08-09 16:04:09:532 Browser.cpp(451) Entering Browser::GetDocumentFromWindow
T 2012-08-09 16:04:09:532 Script.cpp(40) Entering Script::Initialize
T 2012-08-09 16:04:09:532 Script.cpp(210) Entering Script::Execute
T 2012-08-09 16:04:09:532 Script.cpp(577) Entering Script::CreateAnonymousFunction
T 2012-08-09 16:04:09:547 IECommandExecutor.cpp(187) Entering IECommandExecutor::OnGetResponseLength
W 2012-08-09 16:04:09:547 Script.cpp(594) -2147024891 [Access is denied.]: Unable to execute code, call to IHTMLWindow2::execScript failed
W 2012-08-09 16:04:09:547 Script.cpp(221) Cannot create anonymous function
W 2012-08-09 16:04:09:547 ElementFinder.cpp(86) Unable to create criteria object for mechanism 00FBA030 and criteria00FB9FB0

上記の赤で強調表示されたセクションに問題があると思いますが、問題を解決する方法がわかりません。誰にもアイデアはありますか?

4

1 に答える 1

1

ブラウザのセキュリティ設定をチェックして、アクティブ スクリプトが有効になっていることを確認してください。IE9 で有効にするには、次の手順を実行します。 1. [ツール] アイコンをクリックします。(ツール アイコンは IE9 の右上隅にあります。または、ツールはメニュー バーの [ツール] にもあります)。2. [インターネット オプション] -> [セキュリティ] タブ -> [レベルのカスタマイズ] ボタン -> 下部にある [スクリプト] セクションまでスクロールし、[アクティブ スクリプト] で [有効] を選択します。 3. [OK] をクリックします。

于 2012-12-19T21:32:48.007 に答える