Hi, I want to make the tests I do in selenium can be automated in travis, but I have no idea how I have to configure the travis.yml for this, I tried several configurations that I found but none worked. I have been testing the code directly with the default localhost and only with chrome.
Currently my test is as follows
<?php
use PHPUnit\Framework\TestCase;
use Facebook\WebDriver;
require_once('vendor/autoload.php');
class ProbandoIngresarDatosTest extends TestCase
{
/**
* @var WebDriver\Remote\RemoteWebDriver
*/
private $webDriver;
/**
* @var string
*/
private $baseUrl;
/**
* init webdriver
*/
public function setUp():void
{
$desiredCapabilities = WebDriver\Remote\DesiredCapabilities::chrome();
$desiredCapabilities->setCapability('trustAllSSLCertificates', true);
$this->webDriver = WebDriver\Remote\RemoteWebDriver::create('http://localhost:4444/wd/hub', $desiredCapabilities);
}
/**
* Method testProbandoIngresarDatos
* @test
*/
public function testProbandoIngresarDatosYMandarEmail()
{
$this->webDriver->get("http://turismonacionaleinternacional/index.php");
$this->webDriver->findElement(WebDriver\WebDriverBy::linkText("Contacto"))->click();
$this->webDriver->findElement(WebDriver\WebDriverBy::id("nombre"))->click();
$this->webDriver->findElement(WebDriver\WebDriverBy::id("nombre"))->sendKeys("Ezequiel");
$this->webDriver->findElement(WebDriver\WebDriverBy::id("apellido"))->sendKeys("Ledesma");
$this->webDriver->findElement(WebDriver\WebDriverBy::id("email"))->sendKeys("ezequiel.ledesma026@gmail.com");
$this->webDriver->findElement(WebDriver\WebDriverBy::id("telefono"))->click();
$this->webDriver->findElement(WebDriver\WebDriverBy::id("telefono"))->sendKeys("47347866");
$this->webDriver->findElement(WebDriver\WebDriverBy::id("mensaje"))->click();
$this->webDriver->findElement(WebDriver\WebDriverBy::id("mensaje"))->sendKeys("Estoy probando ingresar datos en el formulario");
$this->webDriver->findElement(WebDriver\WebDriverBy::name("submit"))->click();
$this->webDriver->switchTo()->alert()->dismiss();
$this->assertStringContainsString('Ezequiel', $this->webDriver->getTitle());
}
/**
* Close the current window.
*/
public function tearDown():void
{
$this->webDriver->close();
}
/**
* @param WebDriver\Remote\RemoteWebElement $element
*
* @return WebDriver\WebDriverSelect
* @throws WebDriver\Exception\UnexpectedTagNameException
*/
private function getSelect(WebDriver\Remote\RemoteWebElement $element): WebDriver\WebDriverSelect
{
return new WebDriver\WebDriverSelect($element);
}
}
The travis configuration for
language: php
php:
* 7.3
env:
global:
* DISPLAY=:99.0
* BROWSER_NAME="turismonacionaleinternacional"
* SELENIUM_SERVER="https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar" # Latest version including HtmlUnit
services:
* mysql
* xvfb
install:
* "composer install"
script: phpunit --configuration phpunit.xml --coverage-text
before_script:
* wget https://chromedriver.storage.googleapis.com/79.0.3945.36/chromedriver_win32.zip;
* unzip chromedriver_win32.zip;
* "wget https://selenium-release.storage.googleapis.com/3.14/selenium-server-standalone-3.14.0.jar"
* "java -Dwebdriver.chrome.driver=chromedriver -jar selenium-server-standalone-3.14.0.jar "
* php -S localhost:4444 -t test/funcional/ &>>./logs/php-server.log &
* until $(echo | nc localhost 4444); do sleep 1; echo waiting for PHP server on port 4444...; done; echo "PHP server started"
* sleep 30
and now it is stuck in this way and does not take into account the tests
14:15:27.361 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2020-02-09 14:15:27.702:INFO::main: Logging initialized @811ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:15:27.995 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
No output has been received in the last 10m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#build-times-out-because-no-output-was-received