mattisbusycom / php-webdriver-bindings

Automatically exported from code.google.com/p/php-webdriver-bindings
0 stars 0 forks source link

php webdriver running in multiple nodes + multiple browsers simultaneously #36

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Selenium grid using two browsers ( chrome and firefox ) in two different 
nodes.  The nodes are using two different ports in the same machine.

2. For each loop, web driver can launch the browsers in two different nodes. 
But the test cases can run only in the last browser that was launched in that 
node.

What is the expected output? What do you see instead?

Test cases can launch two browsers in two different nodes but the test cases 
run only in the last browser that was launched in the node.  The other browser 
remains idle. Was expecting that test cases will run in both browsers in both 
the nodes. 

What version of the product are you using? On what operating system?

Selenium server 2.31
php webdriver bindings  0.9.0

Windows 7 pro.

Please provide any additional information below.

Original issue reported on code.google.com by mldhon2...@gmail.com on 1 Apr 2013 at 1:05

GoogleCodeExporter commented 9 years ago
Not sure if that's actually a code problem with the PHP bindings or with your 
test setup or Selenium Grid.

Can you provide (attachment or URL links) example (PHPUnit?) test case(s) that 
will reproduce the issue? Test cases that access a public site or something of 
that sort. And also, please specify how you start up the grid & nodes, so that 
we can replicate your test setup and run same type of test against it to debug 
the issue.

And also specify if how you run the tests. Standard PHPUnit, custom test 
runner, running one test after another or somehow running 2+ tests in parallel.

Original comment by manga...@gmail.com on 9 Apr 2013 at 6:28

GoogleCodeExporter commented 9 years ago
Hi,

All the following steps are in the same machine

Start Selenium Grid
java -jar selenium-server-standalone-2.32.0.jar -role hub

In nodes

java -jar selenium-server-standalone-2.14.0.jar -role node  -hub 
http://localhost:4444/grid/register -browser browserName=firefox

java -jar selenium-server-standalone-2.14.0.jar -role node  -hub -port 5556 
http://localhost:4444/grid/register -browser browserName=chrome

phpunit example1

Original comment by mldhon2...@gmail.com on 12 Apr 2013 at 4:07

Attachments:

GoogleCodeExporter commented 9 years ago
Thanks, I'll take a look when I have time. Looking at your grid setup, may I 
ask why you use different Selenium versions for the grid (2.32) vs the nodes 
(2.14)? Different versions may have possibility of introducing potential 
issues. Why not use single version?

Original comment by manga...@gmail.com on 12 Apr 2013 at 6:49

GoogleCodeExporter commented 9 years ago
Hi,

Thanks for your help.

Actually I have used the same Selenium version (2.32.0) in the test. Sorry for 
the typo. 

Original comment by mldhon2...@gmail.com on 12 Apr 2013 at 6:35

GoogleCodeExporter commented 9 years ago
Hi!
Did you have a chance to resolve the issue?
Thanks in advance!

Original comment by tetyana....@gmail.com on 21 May 2013 at 5:48

GoogleCodeExporter commented 9 years ago
After some analysis, this appears to be likely a PHPUnit and/or Selenium Grid 
issue. I recommend you contact those projects (discussion group, file bug/issue 
to project, etc.) before going back to us. Marking this done/resolved for now.

Here are my findings on the problem:

* I can reproduce your problem running the provided tests (though I had to make 
some modifications, mentioned later). Swapping order of the browser array in 
example.php will just make the first browser stuck idle while the second one 
runs, as you describe.

* This projects WebDriver bindings work fine for 2 simultaneous/concurrent 
sessions when run outside of PHPUnit, via a PHP shell. I simply invoke 2 
instances of WebDriver (assigned to different variables), with one to connect 
to FF and one to Chrome in the same shell session. Then I can manipulate each 
instance in real time and see it work fine on each/both browser that's open, 
neither is idle/hung, they listen for commands I send to it from the shell. In 
this test setup, the server setup is same as described. See attached output 
from shell on how to test this out from the shell. For testing with PHP shell, 
under Windows (and Mac, if not using PHP from MacPorts, Brew, etc. but what's 
built in with Mac by default), you'd need something like 
http://fischerlaender.de/php/phpa-norl, since there is no shell access with PHP 
from those installations. You do get if by default with "php -a" from the 
command prompt on Linux (and Mac if using MacPorts/Brew/etc. PHP version).

So if this project's bindings work fine in PHP shell, we know it's not a 
problem with the binding code. If any, it would have to deal with timing issues 
since PHP shell execution is slower than running scripts. But as I mentioned, 
this is likely issue with PHPUnit or Grid, but more likely the former. Why? 
Because same Grid worked fine with PHP shell scenario but not PHPUnit, so it 
seems to point to PHPUnit issue.

Here are my observations regarding your test setup:

1) You're using an improper PHPUnit setup. In your example.php, you are using 
PHPUnit's Selenium2TestCase extension, while still using this project's 
WebDriver bindings. That's a no no.

require_once 'PHPUnit/Extensions/Selenium2TestCase.php';
require_once "/phpwebdriver/WebDriver.php";
abstract class WebdriverTest extends PHPUnit_Extensions_Selenium2TestCase{...}

Stick with one or the other. The PHPUnit Selenium2TestCase extension (a 
continuation/enhancement of the PHPUnit-Selenium extension for Selenium 1 or 
Selenium RC), already offers their own PHP bindings to Selenium 2 / WebDriver. 
So you don't need the ones from this project. Alternatively, you can use this 
projects bindings and not use the PHPUnit one. To avoid potential conflict of 
WebDriver code, if you use this project's bindings, you should instead have 
your starting code be like this:

require_once "/phpwebdriver/WebDriver.php";
abstract class WebdriverTest extends PHPUnit_Framework_TestCase{...}

If you need some better PHPUnit test case templating than what is offered by 
PHPUnit default test case, then you should look at using this as your test case 
template to extend from that's part of this project:

http://code.google.com/p/php-webdriver-bindings/source/browse/trunk/trunk/phpweb
driver/CWebDriverTestCase.php

though you might find it could pale in comparison to what's offered by 
PHPUnit's Selenium2TestCase. And if you find it that way, you should then use 
that project's bindings instead of this one.

https://github.com/sebastianbergmann/phpunit-selenium

2) Your Grid setup, I believe, while still working fine, is not optimal. It's 
based on the old Selenium RC style of defining browsers and starting nodes for 
Grid. The new approach is to define the browser's for each node via a 
DesiredCapabilities JSON text input file supplied with a command line parameter 
when starting the node. I haven't tested under this version config for your 
problem, but you might find this could work better for you. Details can be 
found here:

http://rationaleemotions.wordpress.com/2012/01/23/setting-up-grid2-and-working-w
ith-it/

Original comment by manga...@gmail.com on 9 Jun 2013 at 8:00

Attachments:

GoogleCodeExporter commented 9 years ago
Also, I just recalled something, PHPUnit tests (at least with regards to 
Selenium tests) don't really run in parallel well. So you may have trouble 
running 2+ tests at the same time, even if using Grid. We had our own solution 
to address it at work when we still used PHP with Selenium, I don't know all 
the details and can't share it with you.

There are also some other public projects started to try to address it. This 
may be one of them:

https://github.com/eddiejaoude/phpunit-selenium-parallel

Original comment by manga...@gmail.com on 9 Jun 2013 at 8:11