Ejemplo n.º 1
0
 protected function setUp()
 {
     parent::setUp();
     $capabilities = DesiredCapabilities::firefox();
     $host = 'http://localhost:4444/wd/hub';
     $this->driver = RemoteWebDriver::create($host, $capabilities, 45000);
 }
Ejemplo n.º 2
0
 function __construct()
 {
     $host = 'http://localhost:4444/wd/hub';
     // this is the default
     $capabilities = DesiredCapabilities::firefox();
     $this->driver = RemoteWebDriver::create($host, $capabilities);
 }
Ejemplo n.º 3
0
 private static function createUserAgentSpecifiedFirefoxDriver($ua)
 {
     $profile = new \FireFoxProfile();
     $profile->setPreference('general.useragent.override', $ua);
     $caps = \DesiredCapabilities::firefox();
     $caps->setCapability(\FirefoxDriver::PROFILE, $profile);
     return \RemoteWebDriver::create(static::HUB_URL, $caps);
 }
 /**
  * Создаем connect
  */
 private function set_up()
 {
     $host = 'http://localhost:4444/wd/hub';
     // this is the default
     $capabilities = DesiredCapabilities::firefox();
     $this->web_driver = RemoteWebDriver::create($host, $capabilities, 5000);
     // $this->web_driver->manage()->timeouts()->pageLoadTimeout(10);
     $this->web_driver->get(self::URL_BASE);
 }
Ejemplo n.º 5
0
 static function start($browser)
 {
     $seleniumHost = "http://" . Config::get("SELENIUM_HOST") . ":" . Config::get("SELENIUM_PORT") . "/wd/hub";
     switch ($browser) {
         case "chrome":
             putenv("webdriver.chrome.driver=" . Config::get("CHROME_WEBDRIVER_PATH"));
             $capabilities = \DesiredCapabilities::chrome();
             $options = new \ChromeOptions();
             $options->addArguments(array("--start-maximized"));
             $options->addArguments(array("applicationCacheEnabled=1"));
             $capabilities->setCapability(\ChromeOptions::CAPABILITY, $options);
             break;
         case "ie":
             $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => "Internet Explorer");
             break;
         case "firefox_with_firebug":
             $profile = new \FirefoxProfile();
             $profile->setPreference('extensions.firebug.currentVersion', Config::get("FIREBUG_VERSION"));
             $profile->setPreference("extensions.firebug.allPagesActivation", "on");
             $profile->setPreference("extensions.firebug.defaultPanelName", "net");
             $profile->setPreference("extensions.firebug.net.enableSites", true);
             // Set default NetExport preferences
             $profile->setPreference("extensions.firebug.netexport.alwaysEnableAutoExport", true);
             $profile->setPreference("extensions.firebug.netexport.defaultLogDir", Config::get("LOG_PATH"));
             $profile->setPreference("extensions.firebug.netexport.showPreview", false);
             $profile->setPreference("extensions.firebug.netexport.autoExportToFile", true);
             $profile->setPreference("extensions.firebug.netexport.autoExportToServer", false);
             $profile->setPreference("extensions.firebug.netexport.includeResponseBodies", true);
             //$profile->setPreference("extensions.firebug.netexport.pageLoadedTimeout", 5000);
             $profile->addExtension(Config::get("FIREBUG_XPI_PATH"))->addExtension(Config::get("NET_EXPORT_XPI_PATH"));
             $capabilities = \DesiredCapabilities::firefox();
             $capabilities->setCapability(\FirefoxDriver::PROFILE, $profile);
             break;
         case "chrome_default_profile":
             putenv("webdriver.chrome.driver=" . Config::get("CHROME_WEBDRIVER_PATH"));
             $capabilities = \DesiredCapabilities::chrome();
             $options = new \ChromeOptions();
             $options->addArguments(array("start-maximized"));
             $options->addArguments(array("applicationCacheEnabled=1"));
             $options->addArguments(array("user-data-dir=" . Config::get("BROWSER_DATA_DIR")));
             $capabilities->setCapability(\ChromeOptions::CAPABILITY, $options);
             break;
         case "firefox_default_profile":
             // TODO: not working correctly. Need fix
             putenv("webdriver.firefox.profile=default");
             $profile = new \FirefoxProfile();
             $profile->setPreference("webdriver.firefox.profile", "default");
             //$profile->setPreference("webdriver.load.strategy", "unstable");
             $capabilities = \DesiredCapabilities::firefox();
             $capabilities->setCapability(\FirefoxDriver::PROFILE, $profile);
             break;
         default:
             // firefox by default
             $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => "firefox");
     }
     self::$driver = \RemoteWebDriver::create($seleniumHost, $capabilities, 90000, 90000);
 }
Ejemplo n.º 6
0
 private function _initDriver()
 {
     $host = 'http://' . $this->_seleniumHost() . ':' . $this->_seleniumPort() . '/wd/hub';
     $driverName = $this->_seleniumDriver();
     if ($driverName === 'firefox') {
         $capabilities = \DesiredCapabilities::firefox();
     } elseif ($driverName === 'chrome') {
         $capabilities = \DesiredCapabilities::chrome();
     } else {
         throw new Exception("Invalid driver name {$driverName}");
     }
     $this->_driver = \RemoteWebDriver::create($host, $capabilities, $this->_seleniumTimeout());
 }
 public static function setUpBeforeClass()
 {
     global $rssObjectName;
     self::$rssObjectName = $rssObjectName;
     $host = 'http://localhost:4444/wd/hub';
     // this is the default
     $capabilities = DesiredCapabilities::firefox();
     self::$webDriver = RemoteWebDriver::create($host, $capabilities, 5000);
     self::$webDriver->manage()->timeouts()->implicitlyWait(3);
     // implicitly wait time => 3 sec.
     self::$webDriver->manage()->window()->maximize();
     // maxize browser window
     self::$webDriver->get(self::$url);
     // go to RoomSharing System
     self::$helper = new ilRoomSharingAcceptanceSeleniumHelper(self::$webDriver, self::$rssObjectName);
 }
Ejemplo n.º 8
0
 public function __construct($verbose = "false", $host = "localhost", $port = "4444")
 {
     // Set verbose mode - for development testing
     $this->verbose = $verbose;
     // Get the configuration from Configurator
     // If configuaration has a problem stop processing
     $this->configarray = $this->getConfig();
     if ($this->configarray === false) {
         return "Problem with config. Check and restart.";
     }
     $this->steps = isset($this->configarray['steps']) ? $this->configarray['steps'] : null;
     // Require steps now - everything will be performed thru steps
     if ($this->steps == NULL) {
         return "Nothing to do. Check your configuration. Steps are required.";
     }
     $this->elements = isset($this->configarray['elements']) ? $this->configarray['elements'] : null;
     if (isset($this->configarray['site'])) {
         $this->site = $this->configarray['site'];
     } else {
         return "Missing site. Check your config XML and correct.";
     }
     $dhost = 'http://' . $host . ':' . $port . '/wd/hub';
     $capabilities = DesiredCapabilities::firefox();
     // Build Firefox Profile
     // Additional Options available in Config
     $this->profile = new FirefoxProfile();
     if (isset($this->configarray['firefoxprofile'])) {
         $firefox_config = $this->configarray['firefoxprofile'];
         $this->generateProfile($firefox_config);
     }
     $this->logverbose("Firefox Profile", print_r($this->profile, true));
     $capabilities->setCapability(FirefoxDriver::PROFILE, $this->profile);
     try {
         $this->driver = RemoteWebDriver::create($dhost, $capabilities, 5000);
     } catch (Exception $e) {
         die("Please start WebDriver\n");
     }
     // Start by going to site specified in config
     $this->driver->get($this->site);
 }
Ejemplo n.º 9
0
    $driver->get(wordpress('/wp-login.php'));
    $driver->findElement(WebDriverBy::tagName('body'))->click();
    $driver->findElement(WebDriverBy::name('log'))->clear()->click()->sendKeys('admin');
    $driver->findElement(WebDriverBy::name('pwd'))->sendKeys('admin');
    $driver->findElement(WebDriverBy::tagName('form'))->submit();
    if ($driver->findElement(WebDriverBy::tagName('h2'))->getText() == 'Dashboard') {
        print "Successfully logged into WordPress.\n";
    } else {
        var_dump($driver->getPageSource());
        throw new UnexpectedValueException('Login failed.');
    }
}
function activate_plugin($driver)
{
    $driver->get(wordpress('/wp-admin/plugins.php'));
    $activate_links = $driver->findElements(WebDriverBy::xpath('//a[starts-with(@href, "plugins.php?action=activate&plugin=tinypng-image-compression")]'));
    $deactivate_links = $driver->findElements(WebDriverBy::xpath('//a[starts-with(@href, "plugins.php?action=deactivate&plugin=tinypng-image-compression")]'));
    if (count($activate_links) > 0) {
        $activate_links[0]->click();
    } elseif (count($deactivate_links) > 0) {
        print "Plugin already activated.\n";
    } else {
        var_dump($driver->getPageSource());
        throw new UnexpectedValueException('Activating plugin failed.');
    }
}
register_shutdown_function('restore_wordpress');
$global_phantom_host = 'http://127.0.0.1:4444/wd/hub';
$global_driver = RemoteWebDriver::create($global_phantom_host, DesiredCapabilities::firefox());
$global_session_id = $global_driver->getSessionID();
configure_wordpress_for_testing($global_driver);
 /**
  * Get desired capabilities from config
  * @return DesiredCapabilities|null
  * @throws error browser type not supported
  */
 public function _getCapabilities()
 {
     $capabilities = null;
     switch ($this->_browser['type']) {
         default:
             $this->_error('ERROR Sorry this browser type is not supported.');
             break;
         case 'firefox':
             $profile = new FirefoxProfile();
             $capabilities = DesiredCapabilities::firefox();
             if (isset($this->_browser['extensions'])) {
                 foreach ($this->_browser['extensions'] as $i => $ext_path) {
                     if (!is_file($ext_path)) {
                         $this->_error('ERROR The extension file was not found: ' . $ext_path);
                     }
                     $profile->addExtension($ext_path);
                 }
             }
             // Set download preferences for the browser.
             $profile->setPreference("browser.download.folderList", 2);
             $profile->setPreference("xpinstall.signatures.required", false);
             $capabilities->setCapability(FirefoxDriver::PROFILE, $profile);
             break;
         case 'chrome':
             $options = new ChromeOptions();
             $capabilities = DesiredCapabilities::chrome();
             if (isset($this->_browser['extensions'])) {
                 foreach ($this->_browser['extensions'] as $i => $ext_path) {
                     if (!is_file($ext_path)) {
                         $this->_error('ERROR The extension file was not found: ' . $ext_path);
                     }
                     $options->addExtensions($this->_browser['extensions']);
                 }
             }
             // TODO: set options for auto-download if required. (check firefox preferences above).
             $capabilities->setCapability(ChromeOptions::CAPABILITY, $options);
             break;
     }
     return $capabilities;
 }
Ejemplo n.º 11
0
 public function setUp()
 {
     $this->url = "http://www.quickloja.planned.by";
     $this->driver = RemoteWebDriver::create("http://localhost:4444/wd/hub", DesiredCapabilities::firefox());
     $this->driver->manage()->window()->maximize();
 }
Ejemplo n.º 12
0
<?php

// An example of using php-webdriver.
require_once 'lib/__init__.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://www.tuscanyeyewear.com/');
echo "\n Class - " . get_class($driver) . "\n";
// var_dump($driver->getPageSource());
// // 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('HeadLoginView_HeadLoginStatus'));
$login_text = strtolower(trim($link->getText()));
if ($login_text == "login") {
    $link->click();
}
// // print the title of the current page
// echo "The title is " . $driver->getPageSource() . "'\n";
// // print the title of the current page
// echo "The current URI is " . $driver->getCurrentURL() . "'\n";
Ejemplo n.º 13
0
 protected function setUp()
 {
     $this->url = "http://localhost/phpunit/web/";
     $this->driver = RemoteWebDriver::create("http://localhost:4444/wd/hub", DesiredCapabilities::firefox());
     $this->driver->manage()->window()->maximize();
 }