标签: selenium-grid

Selenium WebDriver - 会话因 CLIENT_GONE 而终止

我正在使用 Selenium WebDriver 在网格模式下运行一套测试。当我运行所有测试并且全部通过时,我的测试套件没有任何问题。

但是,如果测试在 200 个测试套件中失败,如果测试 121 失败,则所有剩余的测试都不会执行,并且我得到的响应为 System.InvalidOperationException: 由于所有测试的 CLIENT_GONE,会话 [] 已终止。

对此的任何指示都会非常有帮助。谢谢

下面是堆栈跟踪

Result2 Name:   AboutThem (Data Row 2)
Result2 Outcome:    Failed
Result2 Duration:   0:11:32.4810094
Result2 StackTrace: 
Server stack trace: 
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(String mechanism, String value)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElementByXPath(String xpath)
at OpenQA.Selenium.By.<>c__DisplayClasse.<XPath>b__c(ISearchContext context)
at OpenQA.Selenium.By.FindElement(ISearchContext context)
at OpenQA.Selenium.Remote.RemoteWebDriver.FindElement(By by)
at WebElementFactory.GetWebElement(IWebDriver driver, String identifier) in C:\WebElementFactory.cs:line 36
at System.Runtime.Remoting.Messaging.Message.Dispatch(Object target)
at system.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]: 
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, …
Run Code Online (Sandbox Code Playgroud)

selenium-grid selenium-firefoxdriver selenium-webdriver

5
推荐指数
0
解决办法
5862
查看次数

Selenium Node driver.manage().window().setPosition(new Point(X,Y)); 没有任何效果

所以我通过 GRID 运行一个足够简单的 Selenium 程序。我的网格和节点所有设置都运行良好。

我遇到的问题如下:

    driver.manage().window().setPosition(new Point(X,Y));
Run Code Online (Sandbox Code Playgroud)

这似乎对节点计算机上的浏览器影响为零。查看服务器,该命令是可以理解的,甚至处理时没有错误:

14:57:02.811 信息 - 完成:[设置窗口位置]

14:57:11.318 信息 - 执行:[获取窗口位置])

使用的代码是

    driver.manage().window().setPosition(new Point(600, 500));
Run Code Online (Sandbox Code Playgroud)

我插入了一些代码来获取浏览器的绳索,它们返回为:

    System.out.println(" POSITION " +driver.manage().window().getPosition());
Run Code Online (Sandbox Code Playgroud)

结果 =“位置 (600, 500)”

我正在使用“import org.openqa.selenium.Point;” 进口。

代码没有其他问题。

我需要移动浏览器的原因是因为第二个浏览器始终与第一个浏览器重叠,从而使 Selenium 无法与第一个浏览器交互(我正在使用并行测试。我调整了两个浏览器的大小以尝试解决问题顺便说一句,调整大小代码(如下)完全没有问题,可以完美运行:

    driver.manage().window().setSize(new Dimension(600, 500));
Run Code Online (Sandbox Code Playgroud)

完整代码:

        DesiredCapabilities cap = DesiredCapabilities.firefox();
        cap.setBrowserName("firefox");
        driver = new RemoteWebDriver(new URL(Node), cap);
        // Puts an Implicit wait, Will wait for 10 seconds before throwing
        driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
        // Launch website
        driver.navigate().to(URL);
        driver.manage().window().setSize(new Dimension(600, 500));
        driver.manage().window().setPosition(new Point(600, 500));
Run Code Online (Sandbox Code Playgroud)

selenium selenium-grid selenium-firefoxdriver selenium-webdriver

5
推荐指数
0
解决办法
4163
查看次数

使用脚本设置 Selenium 网格

设置硒网格:

我能够在命令提示符中使用以下命令设置网格(集线器和节点),然后能够启动浏览器并成功执行测试。

    java -jar selenium-server-standalone-3.4.0.jar -role hub
    java -jar selenium-server-standalone-3.4.0.jar -role webdriver -hub "http://localhost:4444/grid/register" -port 5566
Run Code Online (Sandbox Code Playgroud)

当尝试通过脚本设置硒网格时,我能够成功设置集线器和节点,但无法启动浏览器。

请帮助解决问题。

请找到下面的代码和控制台:

    package config.HubNode;

    import java.net.MalformedURLException;  
    import java.net.URL;    
    import org.openqa.grid.common.RegistrationRequest;  
    import org.openqa.grid.internal.utils.SelfRegisteringRemote;  
    import org.openqa.grid.internal.utils.configuration.GridHubConfiguration;  
    import org.openqa.grid.internal.utils.configuration.GridNodeConfiguration;  
    import org.openqa.grid.web.Hub;  
    import org.openqa.selenium.Platform; 
    import org.openqa.selenium.WebDriver;  
    import org.openqa.selenium.remote.DesiredCapabilities;
    import org.openqa.selenium.remote.RemoteWebDriver;

    public class HubNodeConfig {

    public static void main(String[] args) throws Exception {

        HubNodeConfig objHubNodeConfig = new HubNodeConfig();
        objHubNodeConfig.HubConfig();
        System.out.println("Hub Configured Successfully");

        objHubNodeConfig.NodeConfig();
        System.out.println("Node Configured to Hub Successfully");
        objHubNodeConfig.InvokeBrowser();
    }

    public void HubConfig() throws Exception
    {
        GridHubConfiguration gridHubConfig …
Run Code Online (Sandbox Code Playgroud)

selenium selenium-grid

5
推荐指数
1
解决办法
1159
查看次数

如何从本地主机连接到docker容器

我创建了一个运行 2 个 java 进程的 docker 容器 - 其中一个进程正在侦听端口 4444,并且应该可以通过浏览器访问以下 URL:

http://{主机}:4444/grid/console

如何从主机上的浏览器访问此 URL - 连接到端口 4444 上的容器?

这是 docker 检查的响应:

[
    {
        "Id": "3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde",
        "Created": "2018-02-22T14:54:37.025854258Z",
        "Path": "/bin/bash",
        "Args": [],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 12320,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2018-02-22T14:54:37.487535484Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:422dc563ca3260ad9ef5c47a1c246f5065d7f177ce51f4dd208efd82967ff182",
        "ResolvConfPath": "/var/lib/docker/containers/3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde/hostname",
        "HostsPath": "/var/lib/docker/containers/3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde/hosts",
        "LogPath": "/var/lib/docker/containers/3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde/3bef855324d8c78fcd3a7ac4e52d1641437f221ebe64af5651641d776cfa1bde-json.log",
        "Name": "/hint-env",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "", …
Run Code Online (Sandbox Code Playgroud)

linux selenium-grid docker docker-machine

5
推荐指数
1
解决办法
2万
查看次数

org.openqa.selenium.json.JsonException:预期读取 START_MAP,但结果却是:END。通过 Node 执行测试时读取的最后 0 个字符

我是 Selenium 的新手并开始学习它。但 Selenium Grid 不适合我。使用的服务器版本是selenium-server-standalone-3.14.0.jar。使用命令,集线器和节点正在运行。将节点添加到 hub 的代码是使用 Eclipse 中的 TestNG 编写的。代码如下:

ChromeOptions options = new ChromeOptions();
options.setCapability(CapabilityType.PLATFORM_NAME, Platform.WIN10);             
options.setCapability(CapabilityType.BROWSER_NAME, "chrome");
driver = new RemoteWebDriver(new URL("http://192.xxx.x.xx:48807/wd/hub"), options);             driver.get("https://www.amazon.in/");
Run Code Online (Sandbox Code Playgroud)

运行测试时,出现以下错误并且未创建会话:

org.openqa.selenium.WebDriverException: Unable to parse remote response: 
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:111)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:73)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:548)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:212)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:130)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:143)
    at grid.Node2.f(Node2.java:44)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:124)
    at org.testng.internal.Invoker.invokeMethod(Invoker.java:580)
    at org.testng.internal.Invoker.invokeTestMethod(Invoker.java:716)
    at org.testng.internal.Invoker.invokeTestMethods(Invoker.java:988)
    at org.testng.internal.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:125)
    at org.testng.internal.TestMethodWorker.run(TestMethodWorker.java:109)
    at org.testng.TestRunner.privateRun(TestRunner.java:648)
    at org.testng.TestRunner.run(TestRunner.java:505)
    at …
Run Code Online (Sandbox Code Playgroud)

selenium webdriver selenium-grid selenium-webdriver

5
推荐指数
1
解决办法
2万
查看次数

带有 Internet Explorer 节点的 Selenium 集线器

是否可以将 selenium hub 与 Internet Explorer 节点一起使用?

我可以将 Selenium hub 与 Firefox 和 Chrome 节点结合使用,使用 docker 和 kubernetes 以及https://hub.docker.com/u/selenium上的图像。但在 Selenium 的 docker hub 中没有 Internet Explorer 图像。还有另一种方法可以做到这一点(使用 docker 和 kubernetes)吗?

testing selenium automated-tests selenium-grid selenium-webdriver

5
推荐指数
1
解决办法
4720
查看次数

在 Windows 虚拟机中运行 Docker

使用:

  • 适用于 Windows 10 的 Docker 桌面
  • MobaXterm 到 RDP 到 Windows 10 VM
  • 硒 3.141.59

我目前正在尝试在 docker 容器中运行 selenium Grid,但遇到了一些问题。我在我的 PC 和虚拟机上都启用了 Hyper-V 和容器。

问题是,与我以前的同事不同,我使用的是 Windows 虚拟机而不是 Linux 虚拟机。当我尝试在虚拟机中运行 docker 时,它说我需要启用嵌套虚拟化。

这是正确的还是我不应该在虚拟机上运行 Docker,而是在物理机上运行?

selenium-grid virtual-machine docker docker-swarm mobaxterm

5
推荐指数
1
解决办法
2万
查看次数

如何使用 Selenium Grid 将文件从本地计算机传输到远程 Web 服务器来上传文件

使用 Selenium 网格上传文件:

代码

import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;

public class Main 
{
    
    public static void main(String[] args) throws MalformedURLException
    {
          DesiredCapabilities capabilities = DesiredCapabilities.internetExplorer();
          capabilities.setBrowserName("internet explorer");
    
          RemoteWebDriver driver = new RemoteWebDriver(new URL("http://URL:4444/wd/hub"), capabilities);
          driver.setFileDetector(new LocalFileDetector());
          driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
    
          driver.get("https://url.de/index.xhtml");
          driver.findElement(By.xpath("//*[@id='form:sdsupload']/span")).click();
        
          WebElement addFile = driver.findElement(By.xpath("//input[@type='file']"));
          ((RemoteWebElement) addFile ).setFileDetector(new LocalFileDetector());
          addFile.sendKeys("C:\\daten\\test\\test2.xml");
    }
}
Run Code Online (Sandbox Code Playgroud)

例外

Jun 26, 2020 3:47:43 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFORMATION: Detected dialect: W3C
Exception in thread "main" org.openqa.selenium.InvalidArgumentException: Attempting …
Run Code Online (Sandbox Code Playgroud)

java selenium selenium-grid selenium-webdriver remotewebdriver

5
推荐指数
1
解决办法
1万
查看次数

Selenium Grid不会在另一台计算机上运行Chrome

我有这个问题.在不同的计算机上,我启动HUB和NODE,然后在我初始化Google Chrome的地方运行我的测试,如下所示:

 Selenium selenium = new DefaultSelenium("localhost", 4444, *googlechrome, "http://www.google.com");
 DesiredCapabilities capabilities = DesiredCapabilities.chrome();
 capabilities.setCapability("chrome.switches", Arrays.asList("--start-maximized"));
 WebDriver  driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capabilities);
Run Code Online (Sandbox Code Playgroud)

一切都在我的电脑上正常运行 - Chrome启动并执行脚本.但是,如果我的朋友尝试完全相同,她会收到此错误:

Exception in thread "main" org.openqa.selenium.remote.UnreachableBrowserException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: os.name: 'Windows XP', os.arch: 'x86', os.version: '5.1', java.version: '1.6.0_29'
Driver info: driver.version: RemoteWebDriver
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:435)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:139)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:94)
    at …
Run Code Online (Sandbox Code Playgroud)

selenium webdriver selenium-grid selenium-chromedriver

4
推荐指数
1
解决办法
1万
查看次数

远程webdriver上的Chrome(通过网格)无法启动

我在使用Grid上的远程webdriver功能(使用Firefox和Chrome的1个linux集线器和1个linux节点)启动Chrome的Cucumber测试时遇到了麻烦.Firefox测试非常顺利,但Chrome返回以下错误:

unknown error: Chrome failed to start: exited abnormally
(Driver info: chromedriver=2.2,platform=Linux 3.2.0-23-generic-pae x86) (WARNING: The server did not provide any stacktrace information)
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException:    java.lang.reflect.InvocationTargetException

Command duration or timeout: 20.67 seconds
Build info: version: '2.30.0', revision: 'dc1ef9c', time: '2013-02-19 00:15:27'
System info: os.name: 'Linux', os.arch: 'i386', os.version: '3.2.0-23-generic-pae',      java.version: '1.7.0_25'
Driver info: org.openqa.selenium.chrome.ChromeDriver (org.openqa.selenium.WebDriverException) (Selenium::WebDriver::Error::UnknownError)
Run Code Online (Sandbox Code Playgroud)

浏览器初始化为:

$profile = Selenium::WebDriver::Chrome::Profile.new
$profile['download.prompt_for_download'] = false
$profile['download.default_directory'] = downloads_path

capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
    platform: "Linux",
    version: "",
    "chrome.profile" => $profile)

browser = Watir::Browser.new(
    :remote, …
Run Code Online (Sandbox Code Playgroud)

selenium google-chrome webdriver selenium-grid watir

4
推荐指数
1
解决办法
1万
查看次数