尝试点击DOM时Selenium错误3?

时间:2011-12-30 18:22:20

标签: php selenium

所以我在

这样的页面上尝试了一个问题,遇到了问题

http://store.apple.com/uk/configure/MD235B/A

我正在尝试点击“添加到购物篮”按钮,但是selenium会返回以下回复

stdClass Object
    (
        [sessionId] => 1325263169527
        [status] => 13
        [value] => stdClass Object
            (
                [message] => 
                [suppressed] => Array
                    (
                    )

                [localizedMessage] => 
                [cause] => 
                [class] => java.lang.NullPointerException
                [hCode] => 157938893
                [stackTrace] => Array
                    (
                        [0] => stdClass Object
                            (
                                [fileName] => ClickElement.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 30
                                [className] => org.openqa.selenium.remote.server.handler.ClickElement
                                [nativeMethod] => 
                                [methodName] => call
                                [hCode] => -835585793
                            )

                        [1] => stdClass Object
                            (
                                [fileName] => ClickElement.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 1
                                [className] => org.openqa.selenium.remote.server.handler.ClickElement
                                [nativeMethod] => 
                                [methodName] => call
                                [hCode] => -835585822
                            )

                        [2] => stdClass Object
                            (
                                [fileName] => FutureTask.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 334
                                [className] => java.util.concurrent.FutureTask$Sync
                                [nativeMethod] => 
                                [methodName] => innerRun
                                [hCode] => -99875877
                            )

                        [3] => stdClass Object
                            (
                                [fileName] => FutureTask.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 166
                                [className] => java.util.concurrent.FutureTask
                                [nativeMethod] => 
                                [methodName] => run
                                [hCode] => -820313654
                            )

                        [4] => stdClass Object
                            (
                                [fileName] => ThreadPoolExecutor.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 1110
                                [className] => java.util.concurrent.ThreadPoolExecutor
                                [nativeMethod] => 
                                [methodName] => runWorker
                                [hCode] => -1285150216
                            )

                        [5] => stdClass Object
                            (
                                [fileName] => ThreadPoolExecutor.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 603
                                [className] => java.util.concurrent.ThreadPoolExecutor$Worker
                                [nativeMethod] => 
                                [methodName] => run
                                [hCode] => -242190659
                            )

                        [6] => stdClass Object
                            (
                                [fileName] => Thread.java
                                [class] => java.lang.StackTraceElement
                                [lineNumber] => 722
                                [className] => java.lang.Thread
                                [nativeMethod] => 
                                [methodName] => run
                                [hCode] => -82946343
                            )

                    )

            )

        [class] => org.openqa.selenium.remote.Response
        [hCode] => 189186959
    )

我正打算打电话

session/'.$sid.'/element/coherent_id_2/click

但到目前为止,我尝试点击的任何元素都无法正常工作,与/ text相同,任何人都可以告诉我我做错了什么?

1 个答案:

答案 0 :(得分:0)

错误意味着找不到元素。

在尝试点击页面之前,您是否等到页面完全加载?我认为ID是通过javascript分配给DOM元素的,所以也许请等到页面完全加载后再单击它。