我使用Selenium RC进行测试.现在要执行负载测试,我想运行并行测试用例.有没有办法在不打开浏览器的情况下运行它们?
我正在使用Java与WebDriver.I必须在两帧之间切换.我已经在selenium IDE中记录了测试用例,并且我得到的值为selectFrame relative = top select Frame = middle Frame
但是有一个问题是它无法识别relative = top和middleFrame.如何使用Java在Selenium WebDriver中解决此问题?
我正在运行一些Selenium-Tests.当我直接从Eclipse启动它们时,一切正常.但是当我通过Maven启动它们时会发生以下异常:
org.openqa.selenium.WebDriverException(Failed to connect to binary FirefoxBinary(C:\winapp\Firefox\firefox.exe) on port 7055; process output follows:
null
Build info: version: '2.26.0', revision: '18040', time: '2012-11-02 09:44:45'
System info: os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.6.0_35'
Driver info: driver.version: FirefoxDriver)
Run Code Online (Sandbox Code Playgroud)
我使用的是Firefox 10.0.10 ESR.我也尝试过Selenium 2.25.0.
这是我最新版本的pom.xml:
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.26.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>2.26.0</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.jdom</groupId>
<artifactId>jdom2</artifactId>
<version>2.0.3</version>
</dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)
如果我能为您提供更多信息,请告诉我们.
编辑:更新的pom.xml
edit2:最让我感到奇怪的是,我可以在没有问题的情况下运行eclipse中的测试.它们只是发生,如果我称之为"mvn …
Selenium WebDriver中的页面对象模式是什么?
它的用途是什么?我们如何在Selenium WebDriver中使用它?
例子将不胜感激.
我有一个长串测试,sendKeys()需要太长时间.当我试图设置text程序崩溃的值时.我知道Selenium sendKeys()是测试实际用户输入的最佳方式,但对于我的应用程序,它需要花费太多时间.所以我试图避免它.
有没有办法立即设置价值?
看到这个简单的例子:
var webdriver = require('selenium-webdriver');
var driver = new webdriver.Builder().
withCapabilities(webdriver.Capabilities.chrome()).
build();
driver.get('http://www.google.com');
// find the search input field on google.com
inputField = driver.findElement(webdriver.By.name('q'));
var longstring = "test"; // not really long for the sake of this quick example
// this works but is slow
inputField.sendKeys(longstring);
// no error but no values set
inputField.value = longstring;
// Output: TypeError: Object [object Object] has no method 'setAttributes'
inputField.setAttributes("value", longstring);
Run Code Online (Sandbox Code Playgroud) 我试图找到一个属性的元素.好吧,我可以在Selenium中找到带有Id,tagName,Xpath和所有其他预定义方法的元素.但是,我正在尝试编写一个专门返回WebElement的方法,给定Attribute name和Value作为输入.
List<WebElement> elements = webDriver.findElements(By.tagName("Attribute Name"));
for(WebElement element : elements){
if(element.getText().equals("Value of Particular Attribute")){
return element;
}
else{
return null;
}
}
Run Code Online (Sandbox Code Playgroud)
假设XPath不是一个选项,还有其他更好的方法吗?
我们正在选择我们的无头浏览器驱动程序解决方案,这将是Selenium WebDriver的一些实现.还有就是GhostDriver,利用的是PhantomJS在在一侧和后端HtmlUnitDriver其基于的HtmlUnit另一方.
PhantomJS使用Safari的渲染引擎WebKit来渲染页面,而HtmlUnitDriver使用其他浏览器没有使用的Rhino引擎(它只是"模拟"浏览器行为.最后一个事实被视为con,因为渲染行为可能与流行的浏览器.
我们认为,PhantomJS是一个更强大的候选人.但是,我们并不知道所有事情:)我们的决定是否还应考虑其他因素和权衡取舍?HtmlUnitDriver可以成为更好的解决方案的其他场景?
htmlunit phantomjs selenium-webdriver ghostdriver htmlunit-driver
我正在使用Selenium 2和python绑定从我们的合作伙伴网站获取一些数据.但平均而言,我需要大约13秒才能执行此操作.
我正在寻找一种方法来禁用图像css和flash等.
我正在使用Firefox 3.6并使用pyvirtualdisplay来防止打开firefox窗口.任何其他优化加速Firefox也将有所帮助.
我已经尝试过network.http.*选项,但没有多大帮助.
并且还设置了 permissions.default.image = 2
任何人都可以给我发送示例代码如何验证元素
在Selenium WebDrvier中使用Java
Chrome 59 删除了对https:// user:password@example.com网址的支持.
我有一个C#selenium测试需要在Windows上以" 无头 "模式使用Chrome版本60
ChromeOptions options = new ChromeOptions();
options.AddArgument("headless");
driver = new ChromeDriver(chrome, options);
Run Code Online (Sandbox Code Playgroud)
这是我试图在Windows上处理的SAML身份验证所需对话框:

基于这里给出的答案:如何使用Java处理Selenium WebDriver的身份验证弹出窗口我可以看到在FireFox中处理此问题的几种解决方法,但在无头模式下Chrome 60没有.
在访问测试中的URL之前,我尝试使用以下代码访问带有凭据的URL(没有凭据)但是看起来Chrome 60 存在错误.
goTo("http://user:password@localhost"); // Caches auth, but page itself is blocked
goTo("http://localhost"); // Uses cached auth, page renders fine
// Continue test as normal
Run Code Online (Sandbox Code Playgroud)
我可以看到Firefox中的以下代码处理身份验证,对话框永远不会弹出:
FirefoxProfile profile = new FirefoxProfile();
profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", "https://saml.domain.com");
profile.EnableNativeEvents = false;`
Run Code Online (Sandbox Code Playgroud)
我试过(第二种方法使用的AutoIt),以及适用于Chrome 60,但确实不是在Chrome 60工作的无头模式.
//Use AutoIt to …Run Code Online (Sandbox Code Playgroud) c# basic-authentication selenium-chromedriver selenium-webdriver
selenium ×5
java ×4
python ×2
c# ×1
css ×1
firefox ×1
ghostdriver ×1
htmlunit ×1
javascript ×1
junit ×1
load-testing ×1
maven ×1
node.js ×1
pageobjects ×1
phantomjs ×1
selenium-rc ×1
webdriver ×1