public function testWithoutMagium() { // This test is based off of my own test environment and so everything up until the Twitter authentication will // not work. So ignore the first part. $webDriver = RemoteWebDriver::create('http://*****:*****@data-strategy="twitter"]')); $webDriver->wait()->until(ExpectedCondition::visibilityOf($element)); $element->click(); // Start from here $configurationProvider = new StandardConfigurationProvider(new ConfigurationReader(), new ClassConfigurationReader(), new EnvironmentConfigurationReader()); $collector = new DefaultPropertyCollector(); $action = new AuthenticateTwitter($webDriver, new \Magium\Twitter\Themes\Twitter($configurationProvider, $collector), new Twitter($configurationProvider, $collector)); $action->execute(); $webDriver->quit(); }
function getWebDriverInstance() { // Provide a re-usable webdriver for selenium tests. global $_INI; static $webDriver; if (!isset($webDriver)) { $driverType = getenv('LOVD_SELENIUM_DRIVER'); $host = 'http://localhost:4444/wd/hub'; $capabilities = null; if ($driverType == 'chrome') { // This is the documented way of starting the chromedriver, but it fails. (at least // on my machine with version 2.23) // putenv('webdriver.chrome.driver=/usr/share/chromedriver'); // $webDriver = ChromeDriver::start(); // Start the chrome driver through the selenium server. fwrite(STDERR, 'Connecting to Chrome driver via Selenium at ' . $host . PHP_EOL); $options = new ChromeOptions(); $options->addArguments(array('--no-sandbox')); $capabilities = DesiredCapabilities::chrome(); $capabilities->setCapability(ChromeOptions::CAPABILITY, $options); } else { // Create Firefox webdriver fwrite(STDERR, 'Connecting to Firefox driver via Selenium at ' . $host . PHP_EOL); $capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'firefox'); } $webDriver = LOVDWebDriver::create($host, $capabilities, WEBDRIVER_MAX_WAIT_DEFAULT * 1000, WEBDRIVER_MAX_WAIT_DEFAULT * 1000); // Set time for trying to access DOM elements $webDriver->manage()->timeouts()->implicitlyWait(WEBDRIVER_IMPLICIT_WAIT); if (isset($_INI['test']['xdebug_enabled']) && $_INI['test']['xdebug_enabled'] == 'true') { // Load page of target host. This is necessary to set a cookie. $webDriver->get(ROOT_URL . '/src/'); // Enable remote debugging by setting XDebug session cookie. $webDriver->manage()->addCookie(array('name' => 'XDEBUG_SESSION', 'value' => 'selenium')); } } // Wrap the webdriver instance in a custom processor. return $webDriver; }
/** * @return RemoteWebDriver */ protected function getRemoteWebDriver() { if (null === $this->remoteWebDriver) { $this->remoteWebDriver = RemoteWebDriver::create($this->getKernel()->getContainer()->getParameter('cosma_testing.selenium.remote_server_url'), DesiredCapabilities::chrome()); } return $this->remoteWebDriver; }
public static function createChromeMobile() { // For Chrome. $capabilities = DesiredCapabilities::chrome(); $capabilities->setCapability(ChromeOptions::CAPABILITY, ['mobileEmulation' => ['deviceName' => 'Google Nexus 5']]); $config = WebDriverConfigFactory::createFromEnv(); $config->setBrowserCapabilities($capabilities->toArray()); return self::create($config); }
/** * TestCase constructor. */ public function __construct() { parent::__construct(); $this->createApp(); $this->resetData(); $this->driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', DesiredCapabilities::chrome()); $this->driver->manage()->window()->setSize(new WebDriverDimension(1440, 900)); $this->driver->manage()->window()->setPosition(new WebDriverPoint(0, 0)); }
/** * Initialize a new webdriver connection if needed * * @access public */ public static function get_webdriver() { if (self::$my_webdriver === null) { $capabilities = DesiredCapabilities::chrome(); $driver = RemoteWebDriver::create(Config::$selenium_hub, $capabilities); self::$my_webdriver = $driver; self::$my_webdriver->manage()->timeouts()->implicitlyWait(5); } return self::$my_webdriver; }
protected function setUp() { if (!empty(getenv('TRAVIS'))) { // running on TRAVIS CI $this->WEBSITE = 'http://127.0.0.1:8080'; $this->BROWSER = DesiredCapabilities::firefox(); } else { $this->WEBSITE = 'http://localhost/mylibrary-yii2/app/public/'; $this->BROWSER = DesiredCapabilities::chrome(); } }
public function setUp() { $urlDoSistema = 'http://localhost:8000/'; $hostDoSelenium = 'http://localhost:4444/wd/hub'; //Define o WebDriver $driver = RemoteWebDriver::create($hostDoSelenium, DesiredCapabilities::chrome()); //$this->setHost('localhost'); // Host do servidor Selenium $this->setPort(4444); // Porta do Servidor do Selenium $this->setBrowser('chrome'); $this->setBrowserUrl($urlDoSistema); }
public static function start(DesiredCapabilities $desired_capabilities = null, ChromeDriverService $service = null) { if ($desired_capabilities === null) { $desired_capabilities = DesiredCapabilities::chrome(); } if ($service === null) { $service = ChromeDriverService::createDefaultService(); } $executor = new DriverCommandExecutor($service); $driver = new static(); $driver->setCommandExecutor($executor)->startSession($desired_capabilities); return $driver; }
public function setUp() { parent::setUp(); $this->testId = uniqid(); switch (getenv('CFX_WEB_BROWSER')) { case 'chrome': $browser = DesiredCapabilities::chrome(); break; case 'firefox': $browser = DesiredCapabilities::firefox(); break; } $this->driver = RemoteWebDriver::create(getenv('CFX_WEB_DRIVER'), $browser); }
protected function execute(InputInterface $input, OutputInterface $output) { /** @var TestSuite $testSuite */ $testSuite = (require $input->getOption('test-suite')); $host = $input->getOption('selenium-host'); $facebookDriver = FacebookRemoteWebDriver::create($host, DesiredCapabilities::chrome()); $remoteDriver = new RemoteWebDriver($facebookDriver, Url::fromString($input->getOption('base-url'))); try { $testSuite->execute($remoteDriver); } catch (\Exception $e) { do { $message = $e->getMessage(); } while ($e = $e->getPrevious()); } $report = $this->formatReport($testSuite); $output->writeln((string) $report); if (isset($message)) { $output->writeln("<error>" . $message . "<error>"); } }
public function getErrors(UriInterface $uri) { $host = $this->host . ':' . $this->port . '/wd/hub'; $options = new ChromeOptions(); $options->addExtensions(array(__DIR__ . '/extension/console2var.crx')); $caps = DesiredCapabilities::chrome(); $caps->setCapability(ChromeOptions::CAPABILITY, $options); $driver = RemoteWebDriver::create($host, $caps); $filteredErrors = []; try { $driver->get((string) $uri); $errors = $driver->executeScript("return localStorage.getItem(\"js_errors\")", array()); $errorList = explode('###', $errors); foreach ($errorList as $errorElement) { if ($errorElement != "") { $filteredErrors[] = trim($errorElement); } } } catch (\Exception $e) { $filteredErrors[] = "Selenium/Webdriver crashed. " . $e->getMessage(); } $driver->quit(); return $filteredErrors; }
/** * NOTICE OF LICENSE * * This source file is subject to the Open Software License (OSL 3.0) * For the full copyright and license information, please view the LICENSE * * @category blackakula * @package wdebug * @copyright Copyright (c) Sergii Kyrychenko <*****@*****.**> * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) */ # Server run example: # java -Dwebdriver.chrome.driver="W:\chromedriver.exe" -jar selenium-server-standalone-2.32.0.jar include 'vendor/autoload.php'; $host = 'http://localhost:4444/wd/hub'; $driver = FBRemote\RemoteWebDriver::create($host, FBRemote\DesiredCapabilities::chrome()); $driver->get('http://example.com/'); $debugger = new Wdebug\Debug($driver); $debugger->execute(function ($type, $data) { switch ($type) { case 'deleteLocator': echo 'Deleted locator "' . $data['key'] . "\"\n"; break; case 'setLocator': if (empty($data['oldKey'])) { echo 'Added locator "' . $data['key'] . "\"\n"; } else { echo 'Changed locator "' . $data['oldKey'] . '" -> "' . $data['key'] . "\"\n"; } echo ' - type: ' . $data['locatorType'] . "\n"; echo ' - value: ' . $data['locatorValue'] . "\n";
private function initDriver() { $this->driver = RemoteWebDriver::create($this->driver_host, DesiredCapabilities::chrome()); }
/** * Initialize the suite settings from an associative array. * * @param array $settings Settings array. * * @return $this|TestSuite Same instance for chained method calls. */ private function _initSuiteSettingsFromArray(array $settings) { $this->output("\n" . 'Initialize the test suite settings.'); $suiteSettings = $this->seleniumFactory->createSuiteSettings(); foreach ($settings as $key => $value) { if ($key === 'browser') { $setterName = 'setCapabilities'; switch ($value) { case 'firefox': $value = DesiredCapabilities::firefox(); break; case 'chrome': $value = DesiredCapabilities::chrome(); break; } } else { $setterName = 'set' . ucfirst($key); } if (method_exists($suiteSettings, $setterName)) { if ($value instanceof DesiredCapabilities) { $message = 'Set ' . lcfirst(str_replace('set', '', $setterName)) . ' = ' . $value->getBrowserName(); } else { $message = 'Set ' . lcfirst(str_replace('set', '', $setterName)) . ' = ' . $value; } $this->output($message); call_user_func([$suiteSettings, $setterName], $value); } } $this->suiteSettings = $suiteSettings; return $this; }
protected function setUp() { $host = 'http://localhost:4444/wd/hub'; $browser = DesiredCapabilities::chrome(); $this->webDriver = RemoteWebDriver::create($host, $browser); }
/** * @return DesiredCapabilities The DesiredCapabilities for Chrome with this options. */ public function toCapabilities() { $capabilities = DesiredCapabilities::chrome(); $capabilities->setCapability(self::CAPABILITY, $this); return $capabilities; }
<?php use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; require '../../vendor/autoload.php'; $host = 'http://localhost:4444/wd/hub'; //run all tests in firefox $capabilities = DesiredCapabilities::firefox(); $driver = RemoteWebDriver::create($host, $capabilities, 5000); $f = 0; $s = 0; require 'add_car.php'; require 'delete_car.php'; require 'view_car_details.php'; $driver->close(); print "[firefox] " . ($f + $s) . " tests run. {$s} passed. {$f} failed." . PHP_EOL; //run all tests in chrome $capabilities = DesiredCapabilities::chrome(); $driver = RemoteWebDriver::create($host, $capabilities, 5000); $f = 0; $s = 0; require 'add_car.php'; require 'delete_car.php'; require 'view_car_details.php'; $driver->close(); print "[chrome] " . ($f + $s) . " tests run. {$s} passed. {$f} failed." . PHP_EOL;