Answer the question
In order to leave comments, you need to log in
PHPUnit + Selenium: Pass multiple sites within one test
To carry out the test, you need to go through several sites, let's say social networking sites, and disable your application in test accounts (in order to later check how it connects to social networks).
I create a new test
class class TestSocialReg extends PHPUnit_Extensions_Selenium2TestCase
Next, in setUp, you need to configure the browser
$this->setBrowser('firefox');
$this->setBrowserUrl('https://www.facebook.com');
Undefined index: browserUrl
function testDo() {
$this->url('/facebook');
sleep(1);
$this->setBrowserUrl('http://www.opera.com');
$this->url('/computer');
sleep(1);
}
https://www.facebook.com/computer
$this->setBrowserUrl('http://www.opera.com');
Answer the question
In order to leave comments, you need to log in
If my memory serves me, url() can accept absolute URLs (with a domain), and setBrowserUrl() can set an empty base path. Those. try fixing your code like this:
function setUp() {
$this->setBrowser('firefox');
$this->setBrowserUrl('');
}
function testDo() {
$this->url('https://www.facebook.com/facebook');
$this->url('http://www.opera.com/computer');
}
So far, the only way I've found is quite stupid: Every time in setUp, check a certain status of which sites have already been visited and assign the next one, something like this:
class TestSocialReg extends PHPUnit_Extensions_Selenium2TestCase {
private static $callNumber = 1;
function setUp() {
$this->setBrowser('firefox');
if (self::$callNumber == 1) {
$this->setBrowserUrl('https://www.facebook.com');
} else {
$this->setBrowserUrl('http://opera.com');
}
}
function testDo() {
$this->url('/facebook');
sleep(1);
self::$callNumber++;
}
function testDo2() {
$this->url('/computer');
sleep(1);
self::$callNumber++;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question