public function setUp() { parent::setUp(); $host = 'http://localhost:4444/wd/hub'; $this->driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox()); $this->driver->manage()->window()->maximize(); }
public static function setUpBeforeClass() { parent::setUpBeforeClass(); if (version_compare(PHP_VERSION, '5.3.19', '<')) { self::markTestSkipped('UI test case requires at least PHP 5.3.19.'); } else { if (!class_exists('\\Facebook\\WebDriver\\Remote\\RemoteWebDriver')) { self::markTestSkipped('Could not find RemoteWebDriver class. ' . 'Run "php ../composer.phar install" from the tests folder.'); } } self::$config = phpbb_test_case_helpers::get_test_config(); self::$root_url = self::$config['phpbb_functional_url']; // Important: this is used both for installation and by // test cases for querying the tables. // Therefore table prefix must be set before a board is // installed, and also before each test case is run. self::$config['table_prefix'] = 'phpbb_'; if (!isset(self::$config['phpbb_functional_url'])) { self::markTestSkipped('phpbb_functional_url was not set in test_config and wasn\'t set as PHPBB_FUNCTIONAL_URL environment variable either.'); } if (!self::$webDriver) { try { $capabilities = DesiredCapabilities::firefox(); self::$webDriver = RemoteWebDriver::create(self::$host . ':' . self::$port, $capabilities); } catch (WebDriverCurlException $e) { self::markTestSkipped('PhantomJS webserver is not running.'); } } if (!self::$already_installed) { self::install_board(); self::$already_installed = true; } }
/** * Set Up. * */ public function setUp() { parent::setUp(); $host = 'http://localhost:4444/wd/hub'; // this is the default $capabilities = DesiredCapabilities::firefox(); $this->driver = RemoteWebDriver::create($host, $capabilities, 35000); }
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() { $targetUrl = 'http://phpunit-selenium2-samples.herokuapp.com/01/'; $host = 'http://localhost:4444/wd/hub'; $driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox()); // $this->setHost('localhost'); // Selenium Server Host $this->setPort(4444); // Selenium Server Port $this->setBrowser('firefox'); // firefox, chrome, iexplorer, safari $this->setBrowserUrl($targetUrl); }
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); }
/** * Set user agent */ public function testSetUserAgent() { $useragent = 'Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16'; // setup $capabilities = DesiredCapabilities::firefox(); /** @var FirefoxProfile $profile */ $profile = $capabilities->getCapability(FirefoxDriver::PROFILE); $profile->setPreference('general.useragent.override', $useragent); $this->webDriver = RemoteWebDriver::create('http://' . self::HOST . '/wd/hub', $capabilities); // test $this->webDriver->get('http://demo.mobiledetect.net/'); $elements = $this->webDriver->findElements(WebDriverBy::tagName('h1')); static::assertEquals(3, count($elements)); $elementContainingQuestion = $elements[1]; static::assertEquals('Is your device really a phone?', $elementContainingQuestion->getText()); $this->webDriver->quit(); }
public function __construct($config = []) { parent::__construct($config); $getAllSessions = RemoteWebDriver::getAllSessions($this->host); if ($this->sessionId && ArrayHelper::inMultiArray($this->sessionId, $getAllSessions, 'id')) { $this->driver = RemoteWebDriver::createBySessionID($this->sessionId, $this->host); } else { $desired_capabilities = DesiredCapabilities::firefox(); $fp = new FirefoxProfile(); $desired_capabilities->setCapability(WebDriverCapabilityType::NATIVE_EVENTS, true); if (isset($this->proxy['ip'])) { $this->proxy['port'] = ArrayHelper::getValue($this->proxy, 'port'); $fp->setPreference('network.proxy.ssl_port', $this->proxy['port']); $fp->setPreference('network.proxy.ssl', $this->proxy['ip']); $fp->setPreference('network.proxy.http_port', $this->proxy['port']); $fp->setPreference('network.proxy.http', $this->proxy['ip']); $fp->setPreference('network.proxy.type', 1); } $desired_capabilities->setCapability(FirefoxDriver::PROFILE, $fp); $this->driver = RemoteWebDriver::create($this->host, $desired_capabilities, 600000, 600000); $this->sessionId = $this->driver->getSessionID(); } }
public function testUsingSelenium() { require_once '../vendor/autoload.php'; // start Firefox with 5 second timeout $host = 'http://localhost'; // this is the default $capabilities = DesiredCapabilities::firefox(); $driver = RemoteWebDriver::create($host, $capabilities, 5000); // navigate to 'http://docs.seleniumhq.org/' $driver->get('http://docs.seleniumhq.org/'); // adding cookie $driver->manage()->deleteAllCookies(); $driver->manage()->addCookie(array('name' => 'cookie_name', 'value' => 'cookie_value')); $cookies = $driver->manage()->getCookies(); print_r($cookies); // click the link 'About' $link = $driver->findElement(WebDriverBy::id('menu_about')); $link->click(); // $this->webDriver->get($this->baseUrl); // // $body = $this->webDriver->findElement(WebDriverBy::tagName('body')); // // $this->assertContains(trans('public.words.welcome'), $body->getText()); }
/** * This method is invoked before a test method */ public function setUp() { $this->webDriver = RemoteWebDriver::create($this->seleniumServerUrl, DesiredCapabilities::firefox()); }
/** * Setup test case */ public function setUp() { // DesiredCapabilities::chrome(); $this->webDriver = RemoteWebDriver::create($this->webDriverUrl, DesiredCapabilities::firefox()); }
public function setUp() { $capabilities = DesiredCapabilities::firefox(); $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); // $this->webDriver->manage()->timeouts()->implicitlyWait( 60 ) ; }
<?php use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\WebDriverBy; require_once dirname(dirname(__FILE__)) . '/vendor/autoload.php'; $host = "http://localhost:4444/wd/hub"; $driver = RemoteWebDriver::create($host, DesiredCapabilities::firefox()); $driver->get('http://github.com/'); var_dump($driver->getTitle()); $driver->close();
/** * 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; }
/** * Initialize the suite settings. */ public function __construct() { $this->capabilities = DesiredCapabilities::firefox(); $this->loggingDirectory = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'logs'; $this->compareImageDir = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'expectedImages'; $this->diffImageDir = dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'diffImages'; }
<?php // An example of using php-webdriver. namespace Facebook\WebDriver; use Facebook\WebDriver\Remote\DesiredCapabilities; use Facebook\WebDriver\Remote\RemoteWebDriver; require_once 'vendor/autoload.php'; // start Firefox with 5 second timeout $host = 'http://localhost:4444/wd/hub'; // this is the default $capabilities = DesiredCapabilities::firefox(); $driver = RemoteWebDriver::create($host, $capabilities, 5000); // navigate to 'http://docs.seleniumhq.org/' $driver->get('http://docs.seleniumhq.org/'); // adding cookie $driver->manage()->deleteAllCookies(); $driver->manage()->addCookie(array('name' => 'cookie_name', 'value' => 'cookie_value')); $cookies = $driver->manage()->getCookies(); print_r($cookies); // click the link 'About' $link = $driver->findElement(WebDriverBy::id('menu_about')); $link->click(); // print the title of the current page echo "The title is '" . $driver->getTitle() . "'\n"; // print the URI of the current page echo "The current URI is '" . $driver->getCurrentURL() . "'\n"; // Search 'php' in the search box $input = $driver->findElement(WebDriverBy::id('q')); $input->sendKeys('php')->submit(); // wait at most 10 seconds until at least one result is shown
public function testShouldSetupFirefoxProfileAndDisableReaderViewForFirefoxBrowser() { $capabilities = DesiredCapabilities::firefox(); /** @var FirefoxProfile $firefoxProfile */ $firefoxProfile = $capabilities->getCapability(FirefoxDriver::PROFILE); $this->assertInstanceOf('Facebook\\WebDriver\\Firefox\\FirefoxProfile', $firefoxProfile); $this->assertSame('false', $firefoxProfile->getPreference(FirefoxPreferences::READER_PARSE_ON_LOAD_ENABLED)); }