I am created test using this tutorial http://net.tutsplus.com/tutorials/php/how-to-use-selenium-2-with-phpunit/. And all work fine, but I can launch this test only on Firefox. I read a lot of articles about this in internet, but I don't find any solution. I have Windows XP, PHP 5.4.7, PHPUnit 3.7.13 by Sebastian Bergmann. Before running test I launched selenium-server-standalone-2.28.0.jar. There is my test
<?php
class Example extends PHPUnit_Extensions_Selenium2TestCase
{ protected function setUp()
{
$this->setBrowser("firefox");
$this->setBrowserUrl('http://test.com/');
}
public function testogin()
{
$this->url('http://test.com/');
$this->timeouts()->implicitWait(10000);
$username = $this->byId('user_login');
$username->value('test.ru');
$password = $this->byId('user_pass');
$password->value('test');
$this->byId('login_btn')->click();
}
}
?>
Please, help me run this test on other browsers. If you need more information, ask me. Thanks
Create an XML which will help us in parameterizing the browser name and don't forget to mention parallel="tests" in order to execute in all the browsers simultaneously. Execute the script by performing right-click on the XML file and select 'Run As' >> 'TestNG' Suite as shown below.
With the increasing demand for automation testing, Selenium is one such tool which perfectly fits for Cross Browser Testing of a website. It is very necessary to check the compatibility and performance of the websites on different browsers and operating systems.
PHPunit’s Selenium extension provides a really nice API for that. You can select elements by class name, tag, name, ID, CSS selector, XPath, etc. The method will return a PHPUnit_Extensions_Selenium2TestCase_Element instance which you can use to select other child elements, attributes, etc.
To enable the Chrome browser, you need to download the chromeDriver and specify the path as an option when launching the Selenium server. Is the Document Ready? If your page content is loaded via AJAX, and you don’t want to trigger the tests directly on page load, you’ll want to wait until your page is loaded and your elements are present.
Here is the code to launch the facebook home page in Chrome browser and print the page title in the output console. To launch the chrome browser you, you need to download the chromeDriver executable file which will link your tests in Selenium and the Chrome browser.
Give your users a seamless experience by testing on 3000+ real devices and browsers. Don't compromise with emulators and simulators Home Guide How to run Selenium tests on IE using IE Driver?
For Chrome:
java -jar selenium-server-standalone-<version>.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe
$this->setBrowser('chrome');
in your setUp()-methodI have not tried the IE Driver yet, so I cannot do more for you then point to the docs.
Lastly, try and run your tests on all these browsers, you can give an array with all browsers: https://phpunit.de/manual/4.8/en/selenium.html Again, I haven't tried this one myself yet, so I cannot be more specific then those docs.
Hopefully I have given you enough pointers now... :)
For IE:
Start Selenium with extra argument:
java -jar selenium-server-standalone-.jar -Dwebdriver.chrome.driver=/path/to/chromedriver.exe -Dwebdriver.ie.driver=/path/to/IEDriverServer.exe
Now do $this->setBrowser('iexplore'); in your setUp()-method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With