我是测试自动化和Selenium WebDriver的新手。
我正在尝试为一个私人网站自动化验证系统。
目标是使订单管理系统自动化,该系统允许业主确认他前几天拿到的几个订单。
我所做的是创建一个包含800行的txt文件,代表800个客户,在研究他们的订单并通过单击图像进行确认时循环遍历它们。
我的问题是,有时我的ChromeDriver没有点击图像,即使它是可见的,我得到以下运行时错误:
Exception in thread "JavaFX Application Thread" java.lang.RuntimeException: java.lang.reflect.InvocationTargetException
at javafx.fxml.FXMLLoader$MethodHandler.invoke(Unknown Source)
at javafx.fxml.FXMLLoader$ControllerMethodEventHandler.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Node.fireEvent(Unknown Source)
at javafx.scene.control.Button.fire(Unknown Source)
at com.sun.javafx.scene.control.behavior.ButtonBehavior.mouseReleased(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.scene.control.skin.BehaviorSkinBase$1.handle(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler$NormalEventHandlerRecord.handleBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventHandler.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.EventHandlerManager.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.CompositeEventDispatcher.dispatchBubblingEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.BasicEventDispatcher.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventDispatchChainImpl.dispatchEvent(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEventImpl(Unknown Source)
at com.sun.javafx.event.EventUtil.fireEvent(Unknown Source)
at javafx.event.Event.fireEvent(Unknown Source)
at javafx.scene.Scene$MouseHandler.process(Unknown Source)
at javafx.scene.Scene$MouseHandler.access$1500(Unknown Source)
at javafx.scene.Scene.impl_processMouseEvent(Unknown Source)
at javafx.scene.Scene$ScenePeerListener.mouseEvent(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at com.sun.javafx.tk.quantum.GlassViewEventHandler$MouseEventNotification.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.tk.quantum.GlassViewEventHandler.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.handleMouseEvent(Unknown Source)
at com.sun.glass.ui.View.notifyMouse(Unknown Source)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(Unknown Source)
at com.sun.glass.ui.win.WinApplication$$Lambda$37/1121172875.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.Trampoline.invoke(Unknown Source)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.reflect.misc.MethodUtil.invoke(Unknown Source)
... 60 more
Caused by: org.openqa.selenium.WebDriverException: unknown error: Element <div class="_mck9w _gvoze _tn0ps">...</div> is not clickable at point (353, 495). Other element would receive the click: <div class="_gftfm"></div>
(Session info: chrome=63.0.3239.84)
(Driver info: chromedriver=2.30.477700 (0057494ad8732195794a7b32078424f92a5fce41),platform=Windows NT 6.3.9600 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
Build info: version: '3.8.1', revision: '6e95a6684b', time: '2017-12-01T19:05:14.666Z'
System info: host: 'PC-CASA', ip: '192.168.0.6', os.name: 'Windows 8.1', os.arch: 'amd64', os.version: '6.3', java.version: '1.8.0_20'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptSslCerts: true, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 2.30.477700 (0057494ad87321..., userDataDir: C:\Users\Zakaria\AppData\Lo...}, cssSelectorsEnabled: true, databaseEnabled: false, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: XP, platformName: XP, rotatable: false, takesHeapSnapshot: true, takesScreenshot: true, unexpectedAlertBehaviour: , unhandledPromptBehavior: , version: 63.0.3239.84, webStorageEnabled: true}
Session ID: b87555cc792c28d8bd14e3d2d1b7c888
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:214)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
at org.openqa.selenium.remote.http.JsonHttpResponseCodec.reconstructValue(JsonHttpResponseCodec.java:40)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:80)
at org.openqa.selenium.remote.http.AbstractHttpResponseCodec.decode(AbstractHttpResponseCodec.java:44)
at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:164)
at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:601)
at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:279)
at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:83)
at com.derossiSpa.bot.pageModule.Confirm_Action.execute(Confirm.java:21)
at com.derossiSpa.bot.view.BotController.startBot(BotController.java:144)
... 69 more
这就是我处理图像点击的方法。
try {
WebElement invoiceImage = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='react-root']/section/main/article/div[2]/div/div[1]/div[1]")));
Thread.sleep(400);
invoiceImage.click();
}
catch(org.openqa.selenium.StaleElementReferenceException ex)
{
WebElement invoiceImage = wait.until(ExpectedConditions.elementToBeClickable(By.xpath("//*[@id='react-root']/section/main/article/div[2]/div/div[1]/div[1]")));
Thread.sleep(400);
invoiceImage.click();
}
对决议有什么想法吗?
您使用的chromedriver 2.30来自错误堆栈
(Session info: chrome=63.0.3239.84)
(Driver info: chromedriver=2.30.477700
not clickable at point
是chromedriver 2.30上的一个已知问题,请将您的chromedriver更新到2.33或最新版本,以解决您的问题。
https://bugs.chromium.org/p/chromedriver/issues/detail?id=1852
正如标题所示,我正在尝试创建一个有几个按钮的程序,每个按钮在单击时都会显示一张图片。但是,我想知道,如果不使用此处所示的graphic类,也不使容器全球化,这是否可能。我尝试了这个,但是,我的程序似乎没有将图像添加到我的面板中。 代码如下:
我正在设计一个Gridview,其中每个项目都有一个TextView和ImageView。我试图找到关于如何使ImageView可点击以及GridView项目本身(两者都会触发不同的方法())的教程(逐步更新和清晰的教程)。 这就是我目前掌握的: Activity.java GV适配器.java 结果: 当Item1(Textview)被点击时,它应该点击整个Item并触发GridView的OnI
我有一个问题使我的图像可点击。它是一张推车风格的照片,带有一点数字气泡,告诉你在推车里有多少件物品。div是可点击的,但照片本身是不可点击的。 下面是我的代码: 我还尝试过用一个函数将click事件添加到图像中(“clicking”),我还尝试过将“routerlink='/cart'”添加到图像标记中,但这两种方法都不奏效。 我错过了什么? 提前谢谢!!
我正在开发一个记忆板游戏。规则如下:首先,牌面朝下。当用户单击第一张卡时,它会翻转,当用户单击第二张卡时,它也会翻转,此时这两张卡会相互比较。如果它们是一样的,它们就被从棋盘上取下,如果不是的话,它们将再次面对下。 我有一个GridView和实现翻转和比较的卡片在"onItemclick",但我没有得到预期的结果,因为比较结果总是掩盖第二张卡片的翻转。 例如,如果这两张卡是匹配的,则在用户有机会查
有没有办法将图像分割到区域(现在是JLabel,但如果需要我可以更改它)? 我在我的程序中使用swing,我有一个图像(这个例子是正方形),里面有一些三角形、星星和梯形(它可以是JPG、PNG等)。 这个想法是用户将点击这些形状中的一个,然后我将在用户点击的区域顶部放置另一个小图标。用户可以点击多个区域,但在一天结束时,我需要知道哪些形状被点击。
我有一张地图,上面有很多自定义的大标记。现在,我希望允许用户在地图上创建路径(显示为折线,稍后保存为地理坐标对列表)。 如果用户单击地图,我可以使用地图的setOnMapClickedListener方法收集这些位置。但是如果用户点击一个标记(setOnMarkerClickedListener),我只能检索标记的位置(通常是标记的ancor的位置)。