0
votes

I'm using Selenium stanalone + Chrome headless + PHP + UwAmp server on my computer to parse some data (system: WIN7_32bit, 4GB RAM).

I need to start 22 Chrome sessions at the same time so I'm using selenium grid with this settings:

java -jar selenium-server-standalone-2.53.1.jar -role hub
java -jar selenium-server-standalone-2.53.1.jar -role node -hub http://localhost:4444/grid/register -browser "browserName=chrome,maxInstances=22,seleniumProtocol=WebDriver" -maxSession 22

My problem is that mainly 6 session are started (example on pictures)... Sometimes there are 2 or 4 active sessions. What am I doing wrong? I tried to make changes in php.ini but withouth success. These are the settings:

settings

sessions

EDIT: my php.ini file

EDIT2: since same thing happens on other workstation (WIN10_64bit, Intel i7, 16GB RAM), I think that this problem has something to do with UwAmp server settings, or selenium-server-standalone-2.53.1.jar, or Google Chrome.

1
IMO, your CPU Usage is 100% which is the reason for only 2, 4, or 8 active sessions to spawn out. Shift your Test Environment to a Test Lab with ample hardware to support your Hardware Requirement.DebanjanB
I have tested on computer with Intel I7 processor, 16GB RAM, and the same thing happened...mgulan
Are you sure you are calling quit() in the tearDown() to get rid of stale webdriver and webbrowser instances? Can you share your code block?DebanjanB
Yes, at the end of each PHP script I call:$session->deleteAllCookies(); $session->close();mgulan
Have you looked at this answer stackoverflow.com/questions/45577761/…Kamal Soni

1 Answers

0
votes

Browser connection limitations - exactly that is the problem.

I'm working with PHP (server side language) and I need to execute my PHP scripts somehow. The solution is some local server (like uWamp) and some web browser that opens the script on that server. Since I need to start 22 scripts, at the same time i open 22 browser tabs with this addresses:

http://localhost/selenium/PHPWebDriver/1.php
http://localhost/selenium/PHPWebDriver/2.php
....
http://localhost/selenium/PHPWebDriver/22.php

Now, Chrome limit the number of HTTP connections with the same domain name. This restriction is defined in the HTTP specification (RFC2616) and most modern browsers allow only six connections per domain (Opera, Safari, Chrome, Firefox...)!

So, way to get around browser limits is to:

  1. change the browser limit if plaussible (Firefox), not for Chrome
  2. download browser sources and rebuild them (like Chromium),
  3. providing multiple subdomains,
  4. make user profile for each script (argument for Chrome: '--user-data-dir=').

Maybe there are some other solutions, I don't know...

I decided to go on option 3 since I can't change limits in Chrome.

SOLUTION:

1) Open C:\Windows\System32\drivers\etc\hosts using Notepad

2) Add the following line to the bottom of your hosts file for every subdomain:

127.0.0.1       localhost
127.0.0.1       localhost2
127.0.0.1       localhost3
127.0.0.1       localhost4

(I had to add 4 subdomains because on each subdomain I can execute only 6 scripts)

Now you can start:

http://localhost/selenium/PHPWebDriver/1.php
...
http://localhost/selenium/PHPWebDriver/6.php


http://localhost2/selenium/PHPWebDriver/7.php
...
http://localhost2/selenium/PHPWebDriver/13.php


http://localhost3/selenium/PHPWebDriver/14.php
...etc...

And that's it. Notice that on some servers you might need to make some changes in Apache httpd-vhosts.conf for this to work.

Working!!!