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(); }
public function getDriver() { if (self::$driver == null) { self::$driver = RemoteWebDriver::create('http://127.0.0.1:4444/wd/hub', $this->BROWSER); } return self::$driver; }
/** * @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 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); }
/** * Constructor. Подготовка драйвера Selenium */ public function __construct($seleniumDriverHost = "http://localhost:8910", $driverBrowserName = 'phantomjs', $driverBrowserUserAgent = 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:25.0) Gecko/20100101 Firefox/25.0') { $this->seleniumDriverHost = $seleniumDriverHost; $capabilities = array(WebDriverCapabilityType::BROWSER_NAME => $driverBrowserName, 'phantomjs.page.settings.userAgent' => $driverBrowserUserAgent); $this->driver = RemoteWebDriver::create($seleniumDriverHost, $capabilities, 5000); $window = new WebDriverDimension(1280, 1024); $this->driver->manage()->window()->setSize($window); }
/** * 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; }
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 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); }
public static function create(WebDriverConfig $config) { if (!$config->isValid()) { throw new \Exception('Configuration is invalid. Check that all your properties are defined.'); } $defaultBrowserCapabilities = [WebDriverCapabilityType::BROWSER_NAME => $config->getBrowserName()]; $browserCapabilities = $config->getBrowserCapabilities(); if (empty($browserCapabilities)) { if (!$config->getBrowserProxyHost() && !$config->getBrowserProxyPort()) { $config->setBrowserCapability(WebDriverCapabilityType::PROXY, ['proxyType' => 'manual', 'httpProxy' => $config->getBrowserProxyHost() . ':' . $config->getBrowserProxyPort(), 'sslProxy' => $config->getBrowserProxyHost() . ':' . $config->getBrowserProxyPort()]); } } $browserCapabilities = array_merge($defaultBrowserCapabilities, $config->getBrowserCapabilities()); return RemoteWebDriver::create(sprintf('http://%s:%d/wd/hub', $config->getSeleniumServerHost(), $config->getSeleniumServerPort()), $browserCapabilities); }
/** @BeforeScenario */ public function before($event) { $username = getenv("SAUCE_USERNAME"); $access_key = getenv("SAUCE_ACCESS_KEY"); $platform = getenv("platform"); $browser_name = getenv("browserName"); $version = getenv("version"); $scenario_name = $event->getScenario()->gettitle(); $feature_name = $event->getScenario()->getFeature()->gettitle(); $host = sprintf('http://%s:%s@ondemand.saucelabs.com/wd/hub', $username, $access_key); $desired_capabilities = new stdClass(); $desired_capabilities->platform = $platform; $desired_capabilities->browserName = $browser_name; $desired_capabilities->version = $version; $desired_capabilities->name = $feature_name . " - " . $scenario_name; $this->driver = RemoteWebDriver::create($host, $desired_capabilities); }
/** * 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(); }
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 run() { if ($this->remoteWebDriver === null) { $this->remoteWebDriver = RemoteWebDriver::create('http://127.0.0.1:8910', DesiredCapabilities::phantomjs()); } $script = ''; $script .= file_get_contents(__DIR__ . '/js/jquery-2.2.2.min.js'); $script .= "\n\n"; $script .= file_get_contents(__DIR__ . '/js/frontendscraper.js'); $script .= "\n\n"; while ($job = $this->jobBuffer->getJob()) { $status = $this->createInitStatus($job); $this->remoteWebDriver->get($job->url); $inject = $script; $inject .= file_get_contents($this->jobScriptDir . '/' . $job->script); $inject .= "\n\n return phantomScraper.getResult();"; $res = $this->remoteWebDriver->executeScript($inject); $this->addJobs($res['jobs']); $this->addData($res['data']); $this->updateStatus($status); } }
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()); }
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; }
<?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
/** * 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";
<?php require 'vendor/autoload.php'; require 'config.php'; use Facebook\WebDriver\Exception\WebDriverCurlException; use Facebook\WebDriver\Remote\RemoteWebDriver; use Facebook\WebDriver\Remote\WebDriverCapabilityType; use Facebook\WebDriver\WebDriver; use Facebook\WebDriver\WebDriverBy; $capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'firefox'); $web = RemoteWebDriver::create('http://selenium:4444/wd/hub', $capabilities); $web->get('https://reddit.com/login'); /** * @param $web * @param $input_id * @param $value * @return mixed */ function write_in_input(RemoteWebDriver $web, $input_id, $value) { $input = $web->findElement(WebDriverBy::id($input_id)); $input->click(); $web->getKeyboard()->sendKeys($value); return $input; } function random_ms_sleep() { for ($i = 0; $i < rand(1337, 3000000); $i++) { md5($i); } }
public function setUp() { $capabilities = DesiredCapabilities::firefox(); $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); // $this->webDriver->manage()->timeouts()->implicitlyWait( 60 ) ; }
public function setUp() { parent::setUp(); $capabilities = [WebDriverCapabilityType::BROWSER_NAME => 'firefox']; $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); }
/** * @return Navigator */ protected function _createNavigator() { $capabilities = new DesiredCapabilities([WebDriverCapabilityType::BROWSER_NAME => 'phantomjs']); $driver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); return new Navigator($driver, 'http://localhost:1234'); }
/** * Setup test case */ public function setUp() { // DesiredCapabilities::chrome(); $this->webDriver = RemoteWebDriver::create($this->webDriverUrl, DesiredCapabilities::firefox()); }
/** * This method is invoked before a test method */ public function setUp() { $this->webDriver = RemoteWebDriver::create($this->seleniumServerUrl, DesiredCapabilities::firefox()); }
public function _initializeSession() { $this->webDriver = RemoteWebDriver::create($this->wd_host, $this->capabilities); $this->webDriver->manage()->timeouts()->implicitlyWait($this->config['wait']); }
/** @Given /^I am on "([^"]*)"$/ */ public function iAmOnSite($url) { self::$webDriver = RemoteWebDriver::create("http://*****:*****@hub.browserstack.com/wd/hub", array("platform" => "WINDOWS", "browserName" => "firefox", "browserstack.local" => getenv('WP_ENV') === 'development')); self::$webDriver->get($_SERVER['WP_HOME'] . $url); }