Codeception / module-webdriver

WebDriver module for Codeception
MIT License
36 stars 25 forks source link

Document how to debug browser driver issues #96

Open ThomasLandauer opened 2 years ago

ThomasLandauer commented 2 years ago

@Naktibalda If webdriver isn't getting a connection to the browser, is there a way to debug the interplay between the involved components: Codeception <-> Facebook WebDriver <-> chromedriver <-> chrome? I.e. is there a way to "ping" Facebook WebDriver from Codeception? Then ping chromedriver, etc.?

Naktibalda commented 2 years ago

Facebook WebDriver (now PHP WebDriver - https://github.com/php-webdriver/php-webdriver) is PHP library, there is nothing to ping.

If ChromeDriver is not reachable, you get ConnectionException Can't connect to WebDriver at localhost:4444. Make sure that ChromeDriver, GeckoDriver or Selenium Server is running. on session creation. If session creation succeeded but some later request fails, you get \Facebook\WebDriver\Exception\WebDriverCurlException.

If ChromeDriver fails to launch Chrome, you get something like Could not start a new session. Could not start a new session. Error while creating session with the driver service. Stopping driver service: Driver server process died prematurely. See https://github.com/Codeception/module-webdriver/issues/112 as example.

ThomasLandauer commented 2 years ago

I just spent several hours trying to get ChromeDriver connect with a snap installation of Chromium (default on ubuntu nowadays), and the error message I got was:

[Facebook\WebDriver\Exception\WebDriverException] JSON decoding of remote response failed. Error code: 4 The response: 'unhandled request'

I'm guessing that ChromeDriver was responding with some error message, and WebDriver wasn't able to parse that.

  1. Is there a way to get the "raw" response from ChromeDriver/Chrome?
  2. All docs regarding ChromeDriver (same with Geckodriver) are using a non-PHP syntax, e.g. https://chromedriver.chromium.org/capabilities So the first problem when trying to debug something is to "translate" what they're telling you into the YAML-syntax that Codeception is expecting: https://codeception.com/docs/modules/WebDriver#ChromeDriver Is there a general rule for this "translation"? Or (even better) is there a way to try these options directly on the command line (i.e. outside of Codeception)?
  3. What are you usually doing when it's not working right away?

=> My plan would be to explain these questions at https://codeception.com/docs/modules/WebDriver

Regarding snap: I came to the conclusion that it's not compatible and installed a deb package of Chromium ;-)

Naktibalda commented 2 years ago

Yes, Facebook WebDriver is very bad at handling unexpected responses.

Most likely 'unhandled request' is the raw response that you want to get.