/** @test */ public function sampleTest() { $page = $this->driver->get('http://slovicka.my'); $this->assertContains('Slovicka', $page->getTitle()); $username = $this->driver->findElement(WebDriverBy::name('_username')); $username->sendKeys('*****@*****.**'); }
/** * @dataProvider userLocations */ public function testUserLocation($proxy, $expected) { $this->driver = $this->proxied($proxy); $this->driver->get($this->url); $search = $this->driver->findElement(WebDriverBy::id('user-city')); $this->assertContains($expected, $search->getText()); }
/** * Поиск продукта по названию и переход на страницу * @param String $link_text * @return Page_Product */ public function click_product_by_link_text($link_text) { $wait = new WebDriverWait($this->web_driver, 30); $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::linkText($link_text))); $this->web_driver->findElement(WebDriverBy::linkText($link_text))->click(); return new Page_Product($this->web_driver); }
protected function assertElementNotFound($by) { $els = $this->webDriver->findElements($by); if (count($els)) { $this->fail("Unexpectedly element was found"); } // increment assertion counter $this->assertTrue(true); }
/** * @param RemoteWebDriver $web_driver */ function __construct(RemoteWebDriver $web_driver) { $this->web_driver = $web_driver; // Дожидаемся загрузки первого елемента $wait = new WebDriverWait($this->web_driver, 30); $wait->until(WebDriverExpectedCondition::visibilityOfElementLocated(WebDriverBy::id('MainContent_Email'))); $this->email = $this->web_driver->findElement(WebDriverBy::id('MainContent_Email')); $this->password = $this->web_driver->findElement(WebDriverBy::id('MainContent_Password')); $this->remember = $this->web_driver->findElement(WebDriverBy::id('MainContent_RememberMe')); $this->submit = $this->web_driver->findElement(WebDriverBy::name('ctl00$MainContent$ctl05')); }
function __construct() { $host = 'http://localhost:4444/wd/hub'; // this is the default $capabilities = DesiredCapabilities::firefox(); $this->driver = RemoteWebDriver::create($host, $capabilities); }
/** * @param int $timeout * @return \WebDriverWait */ private function _wait($timeout = null) { if ($timeout === null) { $timeout = 30; } return $this->_driver->wait($timeout); }
protected function setUp() { parent::setUp(); $capabilities = DesiredCapabilities::firefox(); $host = 'http://localhost:4444/wd/hub'; $this->driver = RemoteWebDriver::create($host, $capabilities, 45000); }
/** @Given /^I am on "([^"]*)"$/ */ public function iAmOnSite($url) { print "HHHHHHH >" . $this->tunnel; $desiredCap = array('browser' => $this->BROWSER_NAME, 'browser_version' => $this->BROWSER_VERSION, 'os' => $this->OS, 'os_version' => $this->OS_VERSION, 'browserstack.tunnel' => $this->tunnel); $this->webDriver = RemoteWebDriver::create("http://" . $this->USERNAME . ":" . $this->BROWSERSTACK_KEY . "@hub.browserstack.com/wd/hub", $desiredCap); $this->webDriver->get($url); }
/** * {@inheritdoc}. Override to allow prepending the default host * * @author Ronan Chilvers <*****@*****.**> */ public function get($url) { if ($this->defaultHost && 'http' != substr($url, 0, 4)) { $url = $this->defaultHost . '/' . ltrim($url, '/'); } return parent::get($url); }
protected function setUp() { Phpfox::getService('unittest.test.socialad')->truncateAllRelatedTables(); $host = 'http://localhost:4444/wd/hub'; // this is the default $capabilities = array(WebDriverCapabilityType::BROWSER_NAME => 'firefox'); $this->driver = RemoteWebDriver::create($host, $capabilities); }
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); }
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); }
public function testFacebook() { $url = "http://" . self::$user_id . ":" . self::$security_key . "@hub.browserstack.com/wd/hub"; $caps = array("browser" => "IE", "browser_version" => "9.0", "os" => "Windows", "os_version" => "7", "browserstack.debug" => "true"); $web_driver = RemoteWebDriver::create($url, $caps); $web_driver->get("http://www.facebook.com"); print $web_driver->getTitle(); $web_driver->quit(); }
protected function setUp() { $this->driver = RemoteWebDriver::create( 'http://localhost:4444/wd/hub', array( WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::HTMLUNIT, ) ); }
/** * Создаем 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); }
public static function setUpBeforeClass() { InterfaceTest::$process = proc_open("java \"-Dwebdriver.chrome.driver=res/chromedriver.exe\" -jar res/selenium-server-standalone-2.48.2.jar", [["pipe", "r"], ["pipe", "w"]], $pipe); if (InterfaceTest::$process === false) { throw new Exception("Failed to start selenium server"); } //loads a verified user 'testuser' with blid '4833' and email 'email@email.com` and password 'asdf' TestManager::loadBasicDummyData(); InterfaceTest::$webDriver = RemoteWebDriver::create("http://localhost:4444/wd/hub", DesiredCapabilities::chrome()); }
public function test_header() { putenv('foo=bar'); $w = RemoteWebDriver::create('http://localhost:4444/wd/hub', [WebDriverCapabilityType::BROWSER_NAME => WebDriverBrowserType::HTMLUNIT]); $url = 'http://localhost/mylibrary-yii2/backend/web/site/index'; $w->get($url); echo $w->getPageSource(); //$w->takeScreenshot('1.jpg'); $w->quit(); }
/** * Get the web driver connection * * @return RemoteWebDriver * @author Ronan Chilvers <*****@*****.**> */ protected function getDriver() { if (!$this->driver instanceof Connection) { $this->driver = Connection::create($this->getConnectionUrl(), $this->getCapabilities()); if ($host = $this->getDefaultHost()) { $this->driver->setDefaultHost($host); } } return $this->driver; }
public function testSessionSnapshots() { $this->module->amOnPage('/'); $this->module->setCookie('PHPSESSID', '123456', ['path' => '/']); $this->module->saveSessionSnapshot('login'); $this->module->seeCookie('PHPSESSID'); $this->webDriver->manage()->deleteAllCookies(); $this->module->dontSeeCookie('PHPSESSID'); $this->module->loadSessionSnapshot('login'); $this->module->seeCookie('PHPSESSID'); }
public function applicationRightsResponsibilities() { Automation::grabElementByCssSelector($this->webDriver, 'tr.even:nth-child(6) > td:nth-child(4) > a:nth-child(1) > span:nth-child(1)')->click(); $this->assertEquals('Rights and Responsibilities | NAEYC AMS', $this->webDriver->getTitle()); $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-read-und'))->click(); $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-plan-und'))->click(); $this->webDriver->findElement(WebDriverBy::id('edit-field-rights-verify-und'))->click(); $this->webDriver->findElement(WebDriverBy::id('edit-field-checkbox-list-1-und'))->click(); $this->webDriver->findElement(WebDriverBy::id('edit-field-checkbox-list-2-und'))->click(); $this->webDriver->findElement(WebDriverBy::id('edit-field-text-signature-und-0-value'))->sendKeys('WD'); $this->webDriver->findElement(WebDriverBy::id('edit-submit'))->click(); }
/** * Initializes webdriver. * * @since 1.0.0 * * @access public */ public function _initialize() { $this->wd_host = sprintf('http://%s:%s@hub.browserstack.com/wd/hub', $this->config['username'], $this->config['access_key']); $this->capabilities = $this->config['capabilities']; $this->capabilities[\WebDriverCapabilityType::BROWSER_NAME] = $this->config['browser']; if (!empty($this->config['version'])) { $this->capabilities[\WebDriverCapabilityType::VERSION] = $this->config['version']; } $this->webDriver = \RemoteWebDriver::create($this->wd_host, $this->capabilities); $this->webDriver->manage()->timeouts()->implicitlyWait($this->config['wait']); $this->initialWindowSize(); }
public function testRegisterNewUser() { // $now = time(); // $this->clickRegisterLink(); // $elements_values = array( // 'edit-name' => $now, // 'edit-mail' => "$now@example.com", // 'edit-pass-pass1' => 'password', // 'edit-pass-pass2'=> 'password', // ); // foreach ($elements_values as $key => $value) { // $element = $this->webDriver->findElement(WebDriverBy::id($key)); // $element->clear()->sendKeys($value); // } // $submit = $this->webDriver->findElement(WebDriverBy::id('edit-submit')); // $submit->click(); $now = Automation::registerNewUser($this->webDriver); $messages = $this->webDriver->findElement(WebDriverBy::cssSelector('.messages')); $expected_text = 'Registration successful. You are now logged in.'; $actual_text = $messages->getText(); $this->assertContains($expected_text, $actual_text, 'Registration message'); }
function testLogCreatesNewFileOnFirstMessage() { echo 'This is a test with simple test'; $web_driver = RemoteWebDriver::create("http://<username>:<access_key>@hub.browserstack.com/wd/hub", array("platform" => "WINDOWS")); $web_driver->get("http://www.google.com/ncr"); $this->assertEquals("Google", $web_driver->getTitle()); $element = $web_driver->findElement(WebDriverBy::name("q")); if ($element) { $element->sendKeys("Browserstack"); $element->submit(); //$this->assertEquals(0, count($stack)); } $web_driver->quit(); }
public function setUp() { $capabilities = array(\WebDriverCapabilityType::BROWSER_NAME => 'firefox'); $this->webDriver = RemoteWebDriver::create('http://localhost:4444/wd/hub', $capabilities); $this->app = self::createApplication(); //log user in $this->webDriver->get($this->baseUrl); $usernameField = $this->webDriver->findElement(WebDriverBy::name("username")); $usernameField->sendKeys("superuser"); $passwordField = $this->webDriver->findElement(WebDriverBy::name("password")); $passwordField->sendKeys("mala"); $loginBtn = $this->webDriver->findElement(WebDriverBy::id("login-btn")); $loginBtn->click(); $this->webDriver->manage()->timeouts()->implicitlyWait(1000); }
public function formElementsExist() { $expected_ids = array('edit-submitted-name', 'edit-submitted-email', 'edit-submitted-favorite-muppet'); foreach ($expected_ids as $expected_id) { $this->assertOneOf($expected_id); } $muppet_radios = $this->webDriver->findElements(WebDriverBy::name('submitted[favorite_muppet]')); $actual_muppet_count = count($muppet_radios); $expected_muppet_count = 7; $this->assertEquals($expected_muppet_count, $actual_muppet_count); // This array starts at 1, not 0. for ($i = 1; $i <= $expected_muppet_count; $i++) { $muppet_id = "edit-submitted-favorite-muppet-{$i}"; $this->assertOneOf($muppet_id); } }
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); }
public function testSearch() { $this->webDriver->get($this->url); // find search field by its id $search = $this->webDriver->findElement(WebDriverBy::id('js-command-bar-field')); $search->click(); // typing into field $this->webDriver->getKeyboard()->sendKeys('php-webdriver'); // pressing "Enter" $this->webDriver->getKeyboard()->pressKey(WebDriverKeys::ENTER); $firstResult = $this->webDriver->findElement(WebDriverBy::cssSelector('li.public:nth-child(1) > h3:nth-child(3) > a:nth-child(1) > em:nth-child(2)')); $firstResult->click(); // we expect that facebook/php-webdriver was the first result $this->assertContains("php-webdriver", $this->webDriver->getTitle()); $this->assertEquals('https://github.com/facebook/php-webdriver', $this->webDriver->getCurrentURL()); $this->assertElementNotFound(WebDriverBy::className('avatar')); // $this->waitForUserInput(); }
public function doLogOutLogIn() { if ($this->_testMode < 0) { return; } $username = null; $password = null; $driver = $this->webDriver; $driver->get($this->url . "logout.php"); $driver->wait(15, 300)->until(function ($webDriver) { return $webDriver->getCurrentURL() === $this->url . 'index.php'; }); $indexURL = $this->url . 'index.php'; $currentURL = $this->webDriver->getCurrentURL(); $this->assertEquals($indexURL, $currentURL); if ($indexURL !== $currentURL) { $this->markTestSkipped('Logout page failed.'); return; } $this->assertEquals('PHP Job Seeker 2', $this->webDriver->getTitle()); $this->checkHeaderLoads(); try { $username = $this->webDriver->findElement(WebDriverBy::name('auth_username')); $password = $this->webDriver->findElement(WebDriverBy::name('auth_password')); } catch (NoSuchElementException $ex) { $this->markTestIncomplete('This part of the test has not been written.'); return; } $this->assertNotNull($username); $this->assertNotNull($password); if (null === $username || null === $password) { $this->markTestSkipped('Unable to test login screen - fields missing.'); return false; } $username->sendKeys($this->_userName); $password->sendKeys($this->_password)->submit(); $url = $this->webDriver->getCurrentURL(); $this->assertEquals($this->url . "index.php", $url); $this->assertEquals(true, $this->doWaitFor(WebDriverBy::linkText('Log Out'))); }
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); }