Перейти к содержимому

Публикации fahin

3 публикаций создано fahin (учитываются публикации только с 19 апреля 2023)


#174162 Почему в stderr пишется информация, не являющаяся ошибками в webdriver

Отправлено автор: fahin 23 октября 2019 - 20:13 в Selenium - Functional Testing

Отладка программы - это процесс осознания программистом того, что компьютер делает именно то, что его попросили.

Если вы уйдете в код метода printStackTrace то обнаружите там строчку кода "s.println(this);" где this - ваш webdriver

можно переформулировать вопрос: почему webdriver печатается именно с этими строками, не имеющими отношения к стектрейсу?




#174161 Почему в stderr пишется информация, не являющаяся ошибками в webdriver

Отправлено автор: fahin 23 октября 2019 - 20:12 в Selenium - Functional Testing

Так работает метод printStackTrace() у объекта NoSuchElementException.

Если вам нужен только стектрейс, то берите его - e.getStackTrace() и делайте с ним что хотите.

в приведенном примере, я сам вызываю метод printStackTrace()

но что делать с исключениями, которые появляются в коде естественно, без моего намеренного их создания?

 

может есть какое нибудь property или capability, чтобы можно быть снизить количество выводимых псевдо ошибок?




#174153 Почему в stderr пишется информация, не являющаяся ошибками в webdriver

Отправлено автор: fahin 23 октября 2019 - 15:49 в Selenium - Functional Testing

Здравствуйте

код

try {
            WebElement answerField = driver.findElement(By.cssSelector("#нет такого"));
        } catch (NoSuchElementException e) {
            System.err.println("===============================================");
            e.printStackTrace();
            System.err.println("===============================================");

        }

 выдает такой stacktrace, обрамленный рамкой

===============================================
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#нет такого"}
  (Session info: chrome=77.0.3865.90)
  (Driver info: OperaDriver=76.0.3809.132 (fd1acc410994a7a68ac25bc77513d443f3130860-refs/branch-heads/3809@{#1035}),platform=) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '', ip: '', os.name: '', os.arch: '', os.version: '', java.version: ''
Driver info: org.openqa.selenium.opera.OperaDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 76.0.3809.132 (fd1acc410994..., userDataDir: ...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: , platformName: , proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 77.0.3865.90, webStorageEnabled: true}
Session ID: 6beb05f734bывфвыавфваыв
*** Element info: {Using=css selector, value=#нет такого}
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
	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:158)
	at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
	at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
	at org.openqa.selenium.remote.RemoteWebDriver.findElementByCssSelector(RemoteWebDriver.java:420)
	at org.openqa.selenium.By$ByCssSelector.findElement(By.java:431)
	at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
	at Lol.test(Lol.java:82)
	at Lol.main(Lol.java:24)
===============================================

откуда в stacktrace'e информация, которая stacktrace'ом не является, а именно:

(Session info: chrome=77.0.3865.90)
  (Driver info: OperaDriver=76.0.3809.132 (fd1acc410994a7a68ac25bc77513d443f3130860-refs/branch-heads/3809@{#1035}),platform=) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 0 milliseconds
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:48'
System info: host: '', ip: '', os.name: '', os.arch: '', os.version: '', java.version: ''
Driver info: org.openqa.selenium.opera.OperaDriver
Capabilities {acceptInsecureCerts: false, acceptSslCerts: false, applicationCacheEnabled: false, browserConnectionEnabled: false, browserName: chrome, chrome: {chromedriverVersion: 76.0.3809.132 (fd1acc410994..., userDataDir: ...}, cssSelectorsEnabled: true, databaseEnabled: false, goog:chromeOptions: {debuggerAddress: localhost:}, handlesAlerts: true, hasTouchScreen: false, javascriptEnabled: true, locationContextEnabled: true, mobileEmulationEnabled: false, nativeEvents: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: , platformName: , proxy: Proxy(), rotatable: false, setWindowRect: true, strictFileInteractability: false, takesHeapSnapshot: true, takesScreenshot: true, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unexpectedAlertBehaviour: ignore, unhandledPromptBehavior: ignore, version: 77.0.3865.90, webStorageEnabled: true}
Session ID: 6beb05f734bывфвыавфваыв
*** Element info: {Using=css selector, value=#нет такого}

?

 

также, перед stacktrace'ом в консоли IDE выводится информация красным цветом(что предполагает какие то ошибки)

Starting OperaDriver 76.0.3809.132 (fd1acc410994a7a68ac25bc77513d443f3130860-refs/branch-heads/3809@{#1035}) on port 43894
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1571845821.275][WARNING]: This version of OperaDriver has not been tested with Chrome version 77.
Oct 23, 2019 6:50:23 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS

но это тоже не ошибки

 

почему ее нельзя выводить в stdout?

 

 

p.s. не важную информацию из "stacktrace'a" убрал на всякий случай