0

Selenium WebDriver の使用で問題に直面しています。私は Selenium WebDriver の完全な初心者なので、事前に失礼します。簡単な webdriver テストを作成することで、いくつかの説明を順を追って説明しましたが、まだ機能していません。プロジェクトに webdriver を追加したと言えます。

Firefox 3.5.19 を使っているからだと思われます..。その理由は?これが私のコードです:

    import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxProfile;


public class JobServe {

    /**
     * @param args
     **/
    public static void main(String[] args) {
        // TODO Auto-generated method stub
        FirefoxProfile profile = new FirefoxProfile();
        profile.setPreference("network.proxy.type", 1);
        profile.setPreference("network.proxy.http", "proxyfam");
        profile.setPreference("network.proxy.http_port", 8080);
        WebDriver driver = new FirefoxDriver(profile);


        driver.get("http://www.jobserve.com.au/Homepage.aspx");
        driver.findElement(By.xpath("html/body/form/div[4]/div[1]/div[12]/div[1]/div/div[1]/a[2]/span")).click();
    }

}

そして、ここにエラーログがあります:

Exception in thread "main" org.openqa.selenium.InvalidElementStateException: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsINativeMouse.mouseMove]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js :: anonymous :: line 9839"  data: no]
Command duration or timeout: 62 milliseconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0-OpenSCG-Build-24'
Session ID: e3d70b9d-8b0e-4dca-80e0-6989d0e62497
Driver info: org.openqa.selenium.firefox.FirefoxDriver
Capabilities [{platform=XP, javascriptEnabled=true, acceptSslCerts=true, browserName=firefox, rotatable=false, locationContextEnabled=true, version=3.5.19, cssSelectorsEnabled=true, handlesAlerts=true, nativeEvents=true, webStorageEnabled=true, applicationCacheEnabled=true, takesScreenshot=true}]
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:187)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:145)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:554)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:268)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:79)
    at JobServe.main(JobServe.java:22)
Caused by: org.openqa.selenium.remote.ErrorHandler$UnknownServerException: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsINativeMouse.mouseMove]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js :: anonymous :: line 9839"  data: no]
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0-OpenSCG-Build-24'
Driver info: driver.version: unknown
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:6891)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:9848)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:265)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10421)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10426)
    at <anonymous class>.<anonymous method>(file:///C:/DOCUME~1/plegeard/LOCALS~1/Temp/anonymous1872429321029396376webdriver-profile/extensions/fxdriver@googlecode.com/components/command_processor.js:10366)

誰にもアイデアがありますか?

前もって感謝します。

4

2 に答える 2

1

情報を保持する。Firefox 3.5.19 を使用しています (作業上の制約のため)

Selenium Webdriver を 2.32 から 2.28 にダウングレードすることで、動作するようになりました...

ありがとう。

于 2013-04-22T07:16:17.580 に答える
0

暗黙の待機を試して、クリックする前にこれを試してください

driver.get("http://www.jobserve.com.au/Homepage.aspx");
WebElement maybeClickable = driver.findElement(By.xpath("html/body/form/div[4]/div[1]/div[12]/div[1]/div/div[1]/a[2]/span"))
System.out.println(maybeClickable.isEnabled());

印刷する必要がありますtrue

そうでない場合...その要素はおそらくクリック可能ではありません...

于 2013-04-19T10:54:08.727 に答える