When viewing my app on my local environment, date picklist are in yyyy-mm-dd format. However, viewing the same local environment through Selenium, the date picklists are in dd/mm/yyyy format.
When I run my phpunit test to enter 2024-01-30, it enters the wrong date and later asserts fails.
I must use Edge due to corporate requirements thus I attempted to setup ChromeOptions and pass those to Edge (since it's based off Chrome), but it didn't work.
PHP:
<?php
use MyPlugin\Tests\TestCase;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\WebDriverBy;
use Facebook\WebDriver\WebDriverSelect;
use Facebook\WebDriver\WebDriverExpectedCondition;
use Facebook\WebDriver\Chrome\ChromeDriver;
use Facebook\WebDriver\Chrome\ChromeOptions;
class escalationTest extends TestCase
{
/**
* @var RemoteWebDriver
*/
protected $driver;
protected function setUp(): void
{
// Start a browser session
$capabilities = DesiredCapabilities::microsoftEdge();
$chrome_options = (new ChromeOptions)->addArguments(['--lang' => 'en_CA']);
//$chrome_options = (new ChromeOptions)->addArguments(['--lang=en_CA']);
//set language
$capabilities->setCapability('goog:chromeOptions', $chrome_options);
// Set the options in the capabilities
$capabilities->setCapability('platformName', 'linux');
$this->driver = RemoteWebDriver::create('http://selenium:4444/wd/hub', $capabilities);
}
...
}
?>
Docker:
selenium:
container_name: selenium
image: selenium/standalone-edge:latest
shm_size: 2gb
environment:
LANGUAGE: en_CA.UTF-8
networks:
- frontend
- backend
ports:
- "4444:4444"
- "7900:7900"
Update
I tried using a Dockerfile and setting up the container in a specific language. It didn't work.
Dockerfile:
FROM selenium/standalone-edge:latest
ENV LC_ALL en_CA.UTF-8
ENV LANG en_CA.UTF-8
ENV LANGUAGE en_CA.UTF-8
In the container's terminal:
$ locale
LANG=en_CA.UTF-8
LANGUAGE=en_CA.UTF-8
LC_CTYPE="en_CA.UTF-8"
LC_NUMERIC="en_CA.UTF-8"
LC_TIME="en_CA.UTF-8"
LC_COLLATE="en_CA.UTF-8"
LC_MONETARY="en_CA.UTF-8"
LC_MESSAGES="en_CA.UTF-8"
LC_PAPER="en_CA.UTF-8"
LC_NAME="en_CA.UTF-8"
LC_ADDRESS="en_CA.UTF-8"
LC_TELEPHONE="en_CA.UTF-8"
LC_MEASUREMENT="en_CA.UTF-8"
LC_IDENTIFICATION="en_CA.UTF-8"
LC_ALL=en_CA.UTF-8