2017-12-31 302 views
2

테스트 자동화 및 Selenium WebDriver를 처음 사용했습니다.Image - Selenium WebDriver를 클릭하면 "요소를 클릭 할 때 클릭 할 수 없습니다"Java

개인 웹 사이트의 인증 시스템을 자동화하려고합니다.

목표는 주문 관리 시스템을 자동화하는 것입니다. 그러면 소유자는 이전 날짜에 여러 주문을 확인할 수 있습니다.

TestAutomation은 2/3 일마다 700/800 주문을 확인해야하기 때문에 필요합니다.

기본적으로이 무엇인지 그가하는 (그리고 내가 무엇을 자동화하기 위해 노력하고있어), 다음과 같은 점에 의해 설명 :

1) 그는 로그인 자신의 자격 증명

2 시스템에) 한 번 그는 보안 영역에 있으며 고객의 이름을 입력하는 검색 TextBox를 가지고 있으며 입력 버튼으로 확인하고 고객 세부 정보 페이지로 리디렉션됩니다.

3) 주문을 확인하기 위해 이미지 (인보이스 스캔을 나타냄)를 클릭하고 나타나는 알림에서 예 버튼을 확인합니다.

내가 한 것은 800 명의 고객을 대표하는 800 개의 라인이있는 txt 파일을 작성한 것이고, 주문을 조사하고 이미지를 클릭하여 확인하면 반복됩니다.

내 문제는 가끔 내 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(); 
} 

런타임 오류 10 개 이미지 40 후 correclty, 다른 시간을 클릭 한 후 가끔 그것은 때로는 해결 방법에 대한 유일한 1

어떤 생각 후, 수, 무작위로 실제로 발생?

+0

봅니다 I 2500 MS에서 원래 있었다 이벤트 –

+0

을 클릭하기 전에 좀 더 기다려야 추가 할 수 있지만, 40 개 클릭이 @AnkurSingh 후 실패합니다. 이것은 유일한 해결책이라면 5000 또는 10000으로 늘릴 수 있지만 더 똑똑한 방식으로하고 싶습니다. – user9159143

+0

unk nown error : 요소

...
은 (353, 495) 지점에서 클릭 할 수 없습니다. 다른 요소는 클릭을 수신합니다 :
오류가 귀하의 이미지 링크를 통해 다른 divsion을 클릭한다는 것을 보여주는 오류가 있습니다. 그래서 ~ 5000ms의 대기 시간을 추가하십시오. –

답변

0

당신은 오류 스택에서 chromedriver 2.30 사용되는

(Session info: chrome=63.0.3239.84) 
(Driver info: chromedriver=2.30.477700 

not clickable at point

이 2.33로 chromedriver를 업데이트하거나 최신이 문제를 해결해야한다, 아래 링크에 설명 chromedriver 2.30에 알고 문제입니다 말했다.

https://bugs.chromium.org/p/chromedriver/issues/detail?id=1852