我有一个运行许多测试的selenium测试套件,在每个新测试中,它打开了我打开的任何其他窗口顶部的浏览器窗口.在当地环境中工作时非常震动.有什么办法告诉selenium或操作系统(MAC)在后台打开窗口?
我想知道是否有人可以对一个Selenium让我们有点头疼的问题有所了解.
我们困惑的意义MaxSession和MaxInstances硒电网.我们认为这MaxSession是可以在单个节点上运行的测试会话的总数.我们还认为MaxInstances测试可以打开的浏览器总数.
或者是MaxInstances节点可用的浏览器总数?
我们使用的命令是:
java -Xrs -jar selenium-server.jar -role node -port 44506 -hub http://localhost:44500
/grid/register -firefoxProfileTemplate SeleniumProfile -timeout 300000 -browser
"browserName=firefox,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver" -browser
"browserName=chrome,maxInstances=10,platform=ANY,seleniumProtocol=WebDriver"
Run Code Online (Sandbox Code Playgroud)
我们认为我们使用节点的方式(上面)默认是5个并发测试会话.
每个测试都有20个可用的浏览器吗?
或者每个测试会话是否共享池中的20个浏览器(10 chrome/10 FF) - 与其他测试会话?
我找不到任何关于如何设置它的信息,但它似乎是一个非常基本的概念,所以我确信那里有一个答案.
我知道如何通过在配置中设置对象的browserName属性来在不同的浏览器上运行量角器capabilities.而且这很有效.我可以将它设置为'chrome'或者'firefox'我需要的任何东西,它运行正常.但是,针对多个浏览器运行单个测试套件的唯一方法(据我所知)是创建单独的配置文件,每个配置文件都有不同的browserName,然后使用自己的配置运行每个浏览器.这可行,但它真的很慢,因为测试然后按顺序运行,而不是同时运行.
有没有办法在多个浏览器上并行运行它?
可以在SauceLabs上完成吗?甚至使用当地的Selenium-Grid?
我们只是想简化我们的测试流程,这将是一个巨大的帮助.任何建议或信息将不胜感激.提前致谢.
在Selenium Grid中我试图执行一个简单的程序,Cannot find firefox binary in PATH虽然我已经在我的代码中添加了二进制路径.
我的代码和错误如下.请帮忙.提前致谢.
码
package Sample;
import java.net.MalformedURLException;
import java.net.URL;
import org.openqa.selenium.Platform;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.AfterTest;
public class sample1 {
WebDriver driver;
String BaseURL,NodeURL;
@BeforeTest
public void beforeTest() throws MalformedURLException {
BaseURL="www.google.com";
NodeURL="http://192.168.10.162:5566/wd/hub";
DesiredCapabilities capa =DesiredCapabilities.firefox();
capa.setBrowserName("firefox");
capa.setCapability("binary", "C:\\Users\\praveenraj.d\\AppData\\Local\\Mozilla Firefox\\firefox.exe");
capa.setPlatform(Platform.ANY);
driver=new RemoteWebDriver(new URL(NodeURL),capa);
}
@Test
public void f() throws InterruptedException {
driver.get(BaseURL);
System.out.println(driver.getTitle());
Thread.sleep(50000);
}
@AfterTest
public void afterTest() {
driver.quit();
}
}
Run Code Online (Sandbox Code Playgroud)
错误 …
概述: Chromedriver在一台机器上正常工作,但在另外两台相同的机器上工作速度非常慢.
建立:
我的本地网络上有三台32位Win 7远程计算机(其中两台是虚拟的)都配置为节点.以下是用于启动远程计算机上的节点的命令:
java -jar c:\ seleniumWebDriver\seleniumGrid\selenium-server-standalone-2.31.0.jar -role node -hub http://XXX.XXX.XXX.XXX:4444/grid/register -browser"browserName = chrome" ,maxInstances = 4 -Dwebdriver.chrome.driver ="C:\ seleniumWebDriver\chromedriver.exe"
驱动程序在代码中以这样的方式启动:
DesiredCapabilities capability = new DesiredCapabilities(); capability.SetCapability(CapabilityType.BrowserName,browser); driver = new RemoteWebDriver(new Uri(hubUrl),capability);
上面的变量"browser"和"hubUrl"通过在运行时构建的app.config文件传递.对于这种情况,浏览器= chrome.
问题:
当我使用上面的命令将机器212(它是一个虚拟机)设置为chrome节点,然后从集线器启动脚本时,我在正确的远程机器上看到chrome start并正常运行.它每秒在5-10个命令之间.
当我以相同的方式将机器78(虚拟机)或机器103(真实机器)设置为节点,然后从集线器启动脚本时,我看到节点正确地启动了chrome.但是,它运行速度非常慢,如每秒1次或更少.
其他信息: 就像我说的,在一台机器上镀铬工作正常,但在其他机器上,运行速度非常慢.Firefox和IE配置为节点时,可以正常工作.
我已将机器212(工作正常)与其他机器进行了比较,但无法找到差异.所有机器都使用'selenium-server-standalone-2.31.0.jar'和相同版本的ChromeDriver.
似乎节点机器没有被重载.此外,这是一个非常一致的性能差异,似乎与网络或机器上的任何波动负载无关.
我的网络技术已经验证所有这些机器在网络上配置相同.
以前有人见过这样的事吗?
编辑1:我今天登录,所有三台远程机器都在缓慢运行chrome.在其中一个是正常的之前,但现在他们都很慢.
mstest webdriver selenium-grid selenium-chromedriver selenium-webdriver
我正在使用selenium的python语言绑定.正在测试的应用程序是WEBRTC应用程序,它将调试信息写入浏览器的控制台日志.运行测试时需要获取这些日志信息.当浏览器在同一系统上运行时,我能够获取日志,但是当我在远程浏览器上使用Grid运行相同的代码时,即使它们出现在浏览器中,也不会返回日志.在将节点配置到集线器时,我也尝试使用-browserConsoleLog选项,但即使这样也不起作用.
chrome_opts=webdriver.ChromeOptions()
desired_caps = chrome_opts.to_capabilities()
desired_caps.update({'loggingPrefs':{ 'browser':'ALL'}})
Run Code Online (Sandbox Code Playgroud)
通过启用如上所示的日志记录首选项,我可以在本地运行时从浏览器获取console-api和网络日志,如下所示:
driver=webdriver.Chrome(desired_caps)
driver.get(app_url)
logs = driver.get_log("browser")
# returns all the console-api, network and browser logs as I read from one of the posts
for log in logs:
if log.get('source')=='console-api':
print log.get('message')
Run Code Online (Sandbox Code Playgroud)
但是当我使用与远程浏览器相同的所需功能时,如下所示,get_logs不会返回控制台日志,尽管它出现在浏览器控制台中
driver=webdriver.Remote(command_executor=hub_url,desired_capabilities=desired_caps)
有帮助吗?
python selenium selenium-grid selenium-chromedriver selenium-webdriver
我在Selenium WebDriver中使用Java编写了一些测试用例,并在网格(集线器和多个节点)上执行它们.我注意到一些测试用例由于失败而失败NoSuchElementException.什么是最好和最有效的方法来避免NoSuchElementException和确保始终找到元素?
java selenium-grid selenium-webdriver nosuchelementexception
我正在使用Selenium Remote WebDriver.我从csv文件中读取所有链接并对这些链接运行测试.但有时我得到404回应.
在Selenium WebDriver中是否有任何方法可以检查我们是否获得了HTTP响应200?
他们是否有办法改变Selenium Grid中的Capabilities值?
我已经org.openqa.grid.internal.utils.DefaultCapabilityMatcher在java类中扩展以验证一些值.在传递给节点之前还需要一种方法来替换它们吗?
每次我的webdriver测试登录到应用程序时,出现'你想要chrome保存密码'弹出窗口..有没有办法避免这种情况?
请帮忙.
谢谢,迈克
selenium selenium-grid selenium-rc selenium-chromedriver selenium-webdriver
selenium-grid ×10
selenium ×5
java ×3
webdriver ×2
angularjs ×1
httpresponse ×1
mstest ×1
protractor ×1
python ×1
selenium-rc ×1