硒节点/集线器身份验证 [英] Selenium Node/Hub Authentication

查看:83
本文介绍了硒节点/集线器身份验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过实现自定义代理来停止硒集线器注册节点.我有一些适用于自定义代理的代码.但是,客户端可以通过不在其配置中指定自定义代理来解决此问题.有没有一种方法可以强制节点使用自定义代理而不使用DefaultRemoteProxy.

I am trying to stop a selenium hub registering a node by implementing a custom proxy. I have some code that works for a custom proxy. However, the client can get round this by not specifying the custom proxy in its configuration. Is there a way we can force the node to use the custom proxy and not to use DefaultRemoteProxy.

或者我可以在Selenium Project中实现某些功能以通过Selenium Hub验证节点吗?

Or is there something I can implement within the Selenium Project to authenticate a node with the selenium hub?

推荐答案

没有优雅的方法可以做到这一点. 这是一个肮脏的技巧,您可以使用它来完成这项工作.

There's no elegant way of doing this. Here's a dirty hack using which you can get this done.

  • 创建一个新的标记界面(将其称为Registrable)
  • 创建一个新类,其内容与org.openqa.grid.selenium.proxy.DefaultRemoteProxy的内容重复(我喜欢将此方法称为CLASSPATH重写,但请确保对此有一个更优雅的名称),这样该新类也称为DefaultRemoteProxy,并且它位于同一软件包org.openqa.grid.selenium.proxy中,但位于您的测试项目中.
  • 现在在构造函数中添加如下所示的编辑检查.
  • 现在从该项目中创建一个uber jar,以便可用于分拆Hub.
  • Create a new marker interface (lets call it as Registrable)
  • Create a new class whose contents duplicate the contents of org.openqa.grid.selenium.proxy.DefaultRemoteProxy (I like to call this approach as CLASSPATH overriding but am sure there's a much more elegant name for this ) such that this new class also is called DefaultRemoteProxy and it resides in the same package org.openqa.grid.selenium.proxy but in your test project.
  • Now inside the constructor add an edit check as shown below.
  • Now create an uber jar out of this project so that it can be used to spin off the Hub.

Registrable的外观如下

public interface Registrable {}

这是修改后的DefaultRemoteProxy构造函数的样子:

Here's how the modified constructor of DefaultRemoteProxy would look like :

public DefaultRemoteProxy(RegistrationRequest request, Registry registry) {
 super(request, registry);
 if (!(this instanceof Registrable)) {
  throw new UnsupportedOperationException("Cannot proceed further");
 }
 pollingInterval = config.nodePolling != null ? config.nodePolling : DEFAULT_POLLING_INTERVAL;
 unregisterDelay = config.unregisterIfStillDownAfter != null ? config.unregisterIfStillDownAfter : DEFAULT_UNREGISTER_DELAY;
 downPollingLimit = config.downPollingLimit != null ? config.downPollingLimit : DEFAULT_DOWN_POLLING_LIMIT;
}

现在,您可以调整自定义代理,以使其实现Registrable接口.因此,任何尝试使用DefaultRemoteProxy注册其节点的人都会不断失败,因为DefaultRemoteProxy没有实现Registrable接口.

Now you can tweak your custom proxy such that it implements the Registrable interface. So anyone trying to register their node using DefaultRemoteProxy would constantly fail because DefaultRemoteProxy doesn't implement Registrable interface.

这项工作对您有用吗?

这篇关于硒节点/集线器身份验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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