硒网格会话未应用 [英] Selenium grid sessions not applied

查看:239
本文介绍了硒网格会话未应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在计算机上使用 Stannium stanalone + Chrome无头+ PHP + UwAmp服务器来解析一些数据(系统:WIN7_32bit,4GB RAM).

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

我需要同时启动22个Chrome会话,因此我使用具有以下设置的硒网格:

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

我的问题是主要开始了6个会话(例如在图片上)...有时有2或4个活动会话.我究竟做错了什么?我试图在php.ini中进行更改,但没有成功.这些是设置:

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:

我的php.ini文件

由于其他工作站(WIN10_64bit,Intel i7、16GB RAM)上发生了相同的事情,因此我认为此问题与UwAmp服务器设置或selenium-server-standalone-2.53.1.jar有关,或者谷歌浏览器.

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.

推荐答案

浏览器连接限制-正是问题所在.

我正在使用PHP(服务器端语言),并且需要以某种方式执行我的PHP脚本.解决方案是使用一些本地服务器(如uWamp)和一些在该服务器上打开脚本的Web浏览器.由于我需要启动22个脚本,因此我同时打开以下地址的22个浏览器选项卡:

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

现在,Chrome限制了具有相同域名的HTTP连接的数量.此限制在HTTP规范(RFC2616)中定义,并且大多数现代浏览器每个域(Opera,Safari,Chrome,Firefox ...)仅允许仅六个连接

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. 更改浏览器限制(如果可行)(Firefox),而不是Chrome浏览器
  2. 下载浏览器源并重建它们(例如Chromium)
  3. 提供多个子域,
  4. 为每个脚本创建用户个人资料(Chrome的参数为"--user-data-dir =").

也许还有其他解决方案,我不知道...

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

由于无法在Chrome中更改限制,因此我决定继续执行选项3.

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

解决方案:

1)使用记事本打开C:\ Windows \ System32 \ drivers \ etc \ hosts

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

2)在每个子域的主机文件底部添加以下行:

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

(我必须添加4个子域,因为在每个子域上我只能执行6个脚本)

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

现在您可以开始:

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...

就是这样.请注意,在某些服务器上,您可能需要在Apache httpd-vhosts.conf中进行一些更改才能使其正常工作.

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.

这篇关于硒网格会话未应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆