Issue
I need to make a test using two browser windows at the same time. I am using phpunit with selenium.
Example:
- Open browser1 and navigate to some url
- Copy some dynamic content
- Open browser2, navigate to other url, fill a form with the content of step 2 and submit the form.
I cannot navigate to the url in step 3 from the browser1 because then it will not work.
Right now I cannot open browser2, every attempt I do will use browser1.
Any ideas? Thanks.
Solution
Thanks Keith Tyler. I played a bit with the code and finally I was able to do it.
I will put the code here because it may be usefull for someone.
First thing is to create a class extending PHPUnit_Extensions_Selenium2TestCase:
class Browser extends PHPUnit_Extensions_Selenium2TestCase
{
public function __construct(){
parent::__construct();
$this->setHost("127.0.0.1");
$this->setPort(4444);
$this->setBrowser("firefox");
$this->setBrowserUrl("url");
$this->prepareSession(); // this does the trick
}
}
Then you can use it like this:
$this->url("url1"); // $this will be the default browser
$browser2 = new Browser(); // $browser2 is the new browser and has all the functions from phpunit and selenium available
$browser2->url("url2");
Hope it will save time to someone.
Answered By - Lucas Gonzalez
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.