如果有人知道解决更大问题的替代方法,则提供上下文.
问题背景
我正率先为使用Web组件的Web应用程序开发测试自动化框架.这在Internet Explorer中进行测试时出现了问题,因为Internet Explorer本身不支持Web组件; 相反,polyfill用于提供此功能.
对此的主要反应是,Selenium的大部分将无法按预期工作.它无法像在Firefox和Chrome中那样"看到"Internet Explorer中的Shadow DOM.
另一种方法是编写一个测试框架,它提供了一种通过JavaScript访问元素的替代机制 - 这允许元素通过polyfill定位.
我们当前的实现检查WebDriver正在使用的,并使用方法的原始Selenium实现(在Chrome或Firefox的情况下),或者我们自己的替代实现(在Internet Explorer的情况下).
这意味着我们希望我们的实现尽可能接近Selenium的实现,其核心是浏览器交互级别.
问题
我试图复制的功能Actions.click(WebElement onElement)(源),以简化形式(不继的生成器设计模式Actions类,并使得假设该点击是与鼠标左键并没有其他按键(Ctrl,Shift,Alt)正在举行下).
我想找到处理点击的核心代码(特别是在Chrome,Firefox和Internet Explorer中),所以我可以尽可能地复制它,但是我发现自己迷失在类和接口的深层. ..
创建一个新的ClickAction(源)(以后执行).执行此操作包括对Mouse接口实例(源)进行"click()"调用... aaaa并且我丢失了.我从生成的JavaDoc中看到,它是由EventFiringMouse(源代码)或HtmlUnitMouse(源代码)实现的,但我不确定将实现哪一个.我做了一个假设(没什么基础)HtmlUnitMouse可以使用,这让我进一步深入兔子洞看Gargoyle Software的HTMLUnit代码 ......
简而言之,我完全迷失了.
任何指导将不胜感激:)
研究
RemoteWebDriver(源)由子类ChromeDriver,FirefoxDriver和InternetExplorerDriver.selenium web-component polyfills selenium-webdriver remotewebdriver
始终建议在DesiredCapabilities中设置firefox配置文件,并将其传递到集线器正在运行的线路.如下
DesiredCapabilities caps = DesiredCapabilities.firefox();
FirefoxProfile profile=new FirefoxProfile(new File("Local Path to firefox profile folder"));
caps.setCapability(FirefoxDriver.PROFILE, profile);
URL url = new URL("http://localhost:4444/wd/hub");
WebDriver driver= new RemoteWebDriver(url,caps );
Run Code Online (Sandbox Code Playgroud)
但是,对于每个硒测试案例,将大量的87-90 mb配置文件信息通过http发送到集线器,从而减慢了测试用例的执行速度.
我尝试"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",在json节点配置文件中使用属性配置网格节点,如下所示.
{
"configuration":
{
.//Other Settings
.//Other Settings
.//Other Settings
"Dwebdriver.firefox.profile=E:\\Firefox_Profile_Location":"",
"maxSession":7,
"registerCycle":5000,
"register":true
},
"capabilities":
[
{"browserName":"firefox",
"seleniumProtocol":"WebDriver",
"maxInstances":5,
"platform":"VISTA"
}
]
}
Run Code Online (Sandbox Code Playgroud)
但运行上述配置会导致错误.
WebDriverException:未找到系统属性"webdriver.firefox.profile"中命名的Firefox配置文件"E:\ Firefox_Profile_Location"
高级感谢有关如何从节点端配置firefox配置文件的任何帮助.
如何解决此问题.早些时候我的代码正在运行,但IE设置被某人重置.现在我得到了这个例外.
Started InternetExplorerDriver server (32-bit)
2.53.1.0
Listening on port 16183
Only local connections are allowed
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Attempting bi-dialect session, assuming Postel's Law holds true on the remote end
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to straight W3C remote end connection
Oct 21, 2016 10:14:12 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Falling back to original OSS JSON Wire Protocol.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: Unable to create new remote session. desired capabilities …Run Code Online (Sandbox Code Playgroud) 我有使用两个简单的测试RemoteWebDriver与ChromeOptions和EdgeOptions.这两个测试都使用通用代码来设置功能,包括功能browserstack.user和browserstack.key功能.
因为我使用DriverOptions(而不是DesiredCapabilities)我曾经使用AddAdditionalCapability(...)过这些功能添加到驱动程序.
边缘测试正在运行,但Chrome测试在测试开始之前就失败了;
OpenQA.Selenium.WebDriverException:意外错误.需要授权
DesiredCapabalities在将我的Selenium驱动程序升级到v3.14(DesiredCapabalities已经被删除)之前,这些测试以前一直在使用.
更新
我降级到Selenium.WebDriver v3.4.
传递(EdgeOptions)和失败(使用ChromeOptions)的代码示例:
[TestClass]
public class Simple_GridTest_Chrome
{
private static IWebDriver driver;
private string _bsUsername = "<username>";
private string _bsAccessKey = "<myaccesskey>";
private string _bsProjectName = "TestProject";
private string _bsBuildName = "Build-0.0.1";
private void SetOptions(bool useEdge = false)
{
DriverOptions options;
if (useEdge)
{
options = new EdgeOptions(); // this works OK
} else
{ …Run Code Online (Sandbox Code Playgroud) c# selenium browserstack remotewebdriver desiredcapabilities
我有一个使用Selenium.WebDriver v3.4.0的示例UI测试项目.
当我针对本地驱动程序运行测试时,一切正常,但我想使用Selenium Grid 2来完成工作.
一旦我尝试实例化一个新的RemoteWebDriver,我就会得到一个细节很少的异常.
Driver = new RemoteWebDriver(new Uri(GridUrl), Capabilities);
Run Code Online (Sandbox Code Playgroud)
注意:GridUrl是" http:// localhost:4444/wd/hub "
使用StackTrace引发System.InvalidOperationException,如下所示:
at OpenQA.Selenium.Remote.RemoteWebDriver.UnpackAndThrowOnError(Response errorResponse)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(Uri remoteAddress, ICapabilities desiredCapabilities)
at xxxx.Ui.Tests.SeleniumTests.TestInitialize() in C:\Users\xxxx\Documents\Visual Studio 2015\Projects\xxxx.Ui.Tests\xxxx.Tests\PersonTests.cs:line 38
Run Code Online (Sandbox Code Playgroud)
我在本地运行的集线器v3.4.0具有以下配置:
{
"port": 4444,
"newSessionWaitTimeout": -1,
"servlets" : [],
"withoutServlets": [],
"custom": {},
"capabilityMatcher":"org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
"throwOnCapabilityNotPresent": true,
"cleanUpCycle": 5000,
"role": "hub",
"debug": false,
"browserTimeout": 0,
"timeout": 1800
}
Run Code Online (Sandbox Code Playgroud)
Hub始于:
java -jar selenium-server-standalone-3.4.0.jar -role hub
这已经确定并且看起来正在运行. …
new InternetExplorerDriver();
Run Code Online (Sandbox Code Playgroud)
但我可以看到异常如下:
OpenQA.Selenium.DriverServiceNotFoundException was unhandled by user code
HResult=-2146233088
Message=The IEDriverServer.exe file does not exist in the current directory or in a directory on the PATH environment variable. The driver can be downloaded at http://code.google.com/p/selenium/downloads/list.
Source=WebDriver
StackTrace:
at OpenQA.Selenium.DriverService.FindDriverServiceExecutable(String executableName, Uri downloadUrl)
at OpenQA.Selenium.IE.InternetExplorerDriverService.CreateDefaultService()
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor(InternetExplorerOptions options)
at OpenQA.Selenium.IE.InternetExplorerDriver..ctor()
at Accelrys.CommonTestFramework.WebActions.WebActionLibrary.CreateSeleniumDriver()
Run Code Online (Sandbox Code Playgroud) c# selenium selenium-webdriver remotewebdriver iedriverserver
目前我可以通过RemoteWebDriver发送firefox配置文件,但我无法通过配置文件发送RestCLient扩展.我需要一个REST客户端扩展(firefox附加组件)才能用于我的测试用例执行.
如果我使用firefox驱动程序在本地运行测试用例,它可以工作....但是如何使用RemoteWebDriver实现相同的功能呢?
File profileDirectory = new File("c://mach//lib//prof");
FirefoxProfile profile = new FirefoxProfile(profileDirectory);
driver = new FirefoxDriver(profile);
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
干杯
在使用Java编写的应用程序测试中使用remoteWebDriver尝试建立与selenium-server-standalone的连接后,我收到了一个异常.
问题是(因为由不同的会话的Xvfb,然后硒服务器独立的应用程序测试工作手动运行)相关remoteWebDriver的启动硒服务器独立(带的Xvfb)通过使用maven的使用.环境由RH Linux R4.1.x,Selenium 2.1,firefox 3.6组成.selenium-server-standalone和应用程序测试都在同一台机器(虚拟机)上执行.
如前所述,如果使用以下命令通过单独的PUTTY会话(与用于启动应用程序测试的会话分开)启动此实例,则应用程序测试将成功连接到selenium-server-standalone-2.21.0的实例:
#Xvfb :20 &
#export DISPLAY=:20
#Java –Dwebdriver.firefox.firefox=“/opt/firefox/firefox” –jar selenium-server-standalone-2-.21.0.jar -port 4441.
Run Code Online (Sandbox Code Playgroud)
连接到selenium-server-standalone的应用程序测试代码如下:
DesiredCapabilities capability = DesiredCapabilities.firefox();
capability.setPlatform(Platform.LINUX);
WebDriver driver = new RemoteWebDriver (new URL("http://127.0.0.1:14444/wd/hub"),capability);
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
Run Code Online (Sandbox Code Playgroud)
现在尝试使用maven在启动应用程序测试之前单独启动xvfb和selenium-server-stand我得到以下错误(然后在同一个putty会话中):
selenium server conenction string: http://127.0.0.1:14444/wd/hub
brand community file name orig :/opt/optism_svn/trunk/ITests/Projects/core/bbCampaigns/BrandCommunitiesWD/src/test/resources/Orig_BrandCommunity_Test6386.csv
before connecting to web driver
15:17:05.591 INFO - Executing: [new session: {platform=LINUX, browserName=firefox, version=}] at URL: /session)
15:17:05.651 WARN - Exception thrown
java.util.concurrent.ExecutionException: org.openqa.selenium.WebDriverException: java.lang.reflect.InvocationTargetException
Build info: version: '2.2.1', revision: '16551', time: '2012-04-11 21:42:35'
System …Run Code Online (Sandbox Code Playgroud) 我正在使用具有13个节点的selenium网格,每个节点仅限于一个chrome实例.我的项目在不同时间使用大多数节点.
将来,我需要添加更多节点 - 由于更多的测试,并行执行,不同的浏览器等.问题是我无法确切地知道网格节点的利用率是多少.
有没有办法从网格中获取以下统计信息:
谢谢Tizki
如何通过RemoteWebDriver从公司代理服务器后面连接到诸如BrowserStack之类的selenium网格?
被测试的应用程序在代理之外,可以从BrowserStack免费访问.
这个使用Selenium RemoteWebDriver背后的企业代理(Java) stackoverflow问题提出了同样的问题,但我无法按照接受的答案.