Set custom webdriver port with ENV var and checking port availability by usernameComputer01 · Pull Request #1124 · php-webdriver/php-webdriver

@usernameComputer01

Chrome: WEBDRIVER_CHROME_CUSTOM_PORT
Firefox: WEBDRIVER_FIREFOX_CUSTOM_PORT

@usernameComputer01

    Chrome: WEBDRIVER_CHROME_CUSTOM_PORT
    Firefox: WEBDRIVER_FIREFOX_CUSTOM_PORT

@williamdes

Does such env exist in another project ?
could we use more standard ones ?

@usernameComputer01

Does such env exist in another project ? could we use more standard ones ?

I didn't find any information on the ENV standard for webdriver.

@usernameComputer01

@usernameComputer01 usernameComputer01 changed the title Set custom webdriver port with ENV var Set custom webdriver port with ENV var and checking port availability

Mar 28, 2025

@usernameComputer01

Added checking for availability of listening port

williamdes

williamdes

@usernameComputer01 @williamdes

Co-authored-by: William Desportes <williamdes@wdes.fr>

williamdes

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OndraM

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Could you please update the sockets dependency? 🙏

/**
* @throws RuntimeException
*/
protected static function checkPortIsAvail(int $port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

protected static function checkPortIsAvail(int $port)
protected static function checkPortIsAvailable(int $port)

No need for shortcuts :)

*/
protected static function checkPortIsAvail(int $port)
{
$errTest = static function ($sock) use ($port) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method should check if the Sockets extension is enabled, and if not, it should just return true (ie. the same behavior as before - without free port detection).