WebDriver /'null'不是对象

时间:2013-05-30 13:18:51

标签: selenium safari webdriver

我使用webdrivergrid2。我在MAC计算机中运行集线器,并使用Safari浏览器。

当我运行我的测试时,当我按ID搜索元素时,它会给出下一个异常:

异常

16:12:52: [Exception]: 'null' is not an object (evaluating 'a.split') (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 26 milliseconds
Build info: version: '2.33.0', revision: '4e90c97', time: '2013-05-22 15:32:38'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.8.2', java.version: '1.6.0_37'
Session ID: null
Driver info: org.openqa.selenium.safari.SafariDriver
Capabilities [{platform=MAC, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, takesScreenshot=true, version=6.0.1}]
Command duration or timeout: 4.48 seconds
Build info: version: '2.32.0', revision: '6c40c18', time: '2013-04-09 17:23:22'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.7.0_09'
Session ID: 78100ca3-4843-4a59-8eb6-716b2262e119
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Capabilities [{platform=MAC, javascriptEnabled=true, cssSelectorsEnabled=true, secureSsl=true, browserName=safari, webdriver.remote.sessionid=78100ca3-4843-4a59-8eb6-716b2262e119, takesScreenshot=true, version=6.0.1}]

测试在其他操作系统和其他浏览器中传递(Windows 7使用IE9 / Firefox / Chrome,Windows XP使用FireFox和Chrome)

1 个答案:

答案 0 :(得分:0)

我可以看到这个问题的几种可能性,也许是基本问题:

1)@FindBy(how = How.ID, using = "desc")
你确定'desc'是搜索元素的正确ID吗?顺便说一句,你可以将FindBy缩短为@FindBy(id = "desc")

2)你是否初始化了这个元素?

public UrClass(WebDriver driver)
    {
        this.driver = driver;
        PageFactory.initElements(driver, this);         
    }

3)如果是,您是否能够对给定元素调用任何其他操作?