从RC切换到Selenium Webdriver后,Selenium网格不再工作。请注意,我的大多数测试仍然是RC,但每次都要转换到Webdriver,因此仍然需要Selenium实例。看起来我的驱动程序和/或浏览器(Selenium)实例在并行运行时被覆盖。
下面是我的代码:
public class SeleniumTestSupport
{
private static Properties singleSharedProperties;
private static Selenium webmailsingleSharedBrowser;
protected Selenium webmailbrowser;
protected WebDriver singleSharedDriver;
protected WebDriver driver;
protected Selenium browser;//was protected, now public
protected static String domain;
Integer flag = 0;
@BeforeSuite(alwaysRun = true)
public void startSeleniumClient() {
}
@BeforeTest(alwaysRun = true)
public void distributeTests(){
}
@BeforeClass(alwaysRun = true)
public void initBrowser() {
}
@BeforeMethod(alwaysRun = true)
public void logIn() {
singleSharedProperties = new Properties(System.getProperties());
try {
singleSharedProperties.load(getClass().getClassLoader().getResourceAsStream("selenium.properties"));
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
String serverHost = singleSharedProperties.getProperty("selenium.serverHost", "localhost");
String serverPortText = singleSharedProperties.getProperty("selenium.serverPort", "4444");
int serverPort;
try {
serverPort = Integer.parseInt(serverPortText);
} catch (NumberFormatException e) {
throw new RuntimeException("Unable to parse selenium.serverPort '" + serverPortText + "'");
}
String browserStartCommand = singleSharedProperties.getProperty("selenium.browserStartCommand");
System.out.println("serverhost=" + serverHost);
System.out.println("serverport=" + serverPort);
System.out.println("browserStartCommand=" + browserStartCommand);
System.out.println("url=" + singleSharedProperties.getProperty("teamconnect.url"));
DesiredCapabilities capability = DesiredCapabilities.firefox();
singleSharedDriver = new RemoteWebDriver(capability);
driver=singleSharedDriver;
browser = new WebDriverBackedSelenium(singleSharedDriver, singleSharedProperties.getProperty("teamconnect.url"));
String usernamePassword = singleSharedProperties.getProperty("teamconnect.user." + getUserGroup());
String username = StringUtils.substringBefore(usernamePassword, "/");
String password = StringUtils.substringAfter(usernamePassword, "/");
driver.get(singleSharedProperties.getProperty("teamconnect.url"));
//This code is some setup for each Test, basically, logging into the application...
LoginPage loginPage = new LoginPage(browser);
loginPage.setUsername(username);
loginPage.setPassword(password);
loginPage.clickLogIn();
//more code later, removed for brevity
}
以下是一些更多的信息:
下面是测试的java代码:
@Test
public void testAllowAllAndDenyAllGroupDesignerRights2() {
GlobalNavigationPage globalNavigationPage = new GlobalNavigationPage(browser);
// Click Admin tab from global navigation bar.
globalNavigationPage.clickAdminTab();
Reusable_Actions reusable_Actions = new Reusable_Actions();
Page page = new Page(browser);
public GlobalNavigationPage(Selenium browser) {
super(browser);
}
public void clickAdminTab() {
long start = System.currentTimeMillis();
while (System.currentTimeMillis() - start < WAIT_TIME_IN_SECONDS * 2000) {
// if element is present return
if (browser.isElementPresent(LNK_ADMIN)) {
return;
}
// wait for 1/10 of a second
try {
Thread.sleep(100);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}}
driver.findElement(By.id(LNK_ADMIN)).click();
browser.setTimeout(Integer.toString(WAIT_TIME_IN_SECONDS * 2000));
browser.waitForPageToLoad(Integer.toString(WAIT_TIME_IN_SECONDS * 2000));
assertTextNotPresent("System Error Has Occured!");
}
我猜测您有一个关于如何运行测试的自定义配置。
集线器配置最有可能说明:
仅运行RC测试。
{
"capabilities":
[
{
"browserName": "*firefox",
"maxInstances": 5,
"seleniumProtocol": "Selenium"
},
{
"browserName": "*googlechrome",
"maxInstances": 5,
"seleniumProtocol": "Selenium"
},
{
"browserName": "*iexplore",
"maxInstances": 1,
"seleniumProtocol": "Selenium"
},
{
"browserName": "firefox",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "chrome",
"maxInstances": 5,
"seleniumProtocol": "WebDriver"
},
{
"browserName": "internet explorer",
"maxInstances": 1,
"seleniumProtocol": "WebDriver"
}
],
"configuration":
{
"proxy": "org.openqa.grid.selenium.proxy.DefaultRemoteProxy",
"maxSession": 5,
"port": 5555,
"host": ip,
"register": true,
"registerCycle": 5000,
"hubPort": 4444,
"hubHost": ip
}
}
您可以看到,我们可以为RC测试指定“Selenium”
;为Selenium 2测试指定“webdriver”
。
我正在尝试使用JAXB将我无法控制的XSD转换为Java类。我得到的错误是: XSD中包含错误的代码位于: 具体来说,它是使用布尔类型加密的属性。布尔类型定义为 从四处搜索来看,这似乎是一个比较常见的情况。从我可以看出,mxencrypted行中的默认值不应该是1?当我将XSD加载到液态XML中时,模式不会报告错误。在这里验证XSD(http://www.utilities-online.info
当我使用inspector工具时,它表示元素是一个输入框。我不知道如何解决这个问题,因为我对python非常缺乏经验 输出是一个空字符串,尽管网站显示了一封电子邮件供我使用。
我花了大量的时间试图确定到底出了什么问题,使用LibreOffice将pdf转换为docx(以及doc转换为docx)的代码。 我使用了两个windows run接口来测试运行一些我发现相关的代码,也尝试了python,但两者都不起作用。 我在Windows上安装了LibreOffice v6.0.2。 我一直在使用此代码的变体尝试将某些pdf文件转换为与特定pdf文件不相关的docx: 我已经在
我使用以下方式安装Gatsbyjs: 它安装,然后当我试图创建一个新的网站,它显示一些错误。 我尝试了盖茨比新网站,但它显示了一些错误: PS C:\Users\Klawnny\Dropbox\react电子商务 gatsby-cli@2.7.53更新了一个包在46.004s PS C:\用户\克劳尼\Dropbox\电子商务与反应 文件C:\Users\Klawnny\AppData\Roami
我正在尝试使用与chrome驱动程序selenium连接到一个网站。但联系不上。下面是我的代码: 这段代码给了我一些错误: 页面如下所示: 但预期的页面应该如下所示: 如何访问本网站?
我在使用selenium web驱动程序在两个窗口之间切换时遇到了问题。 我正在使用selenium WebDriver实现网页的自动化。 在父窗口中,我需要单击一个按钮,它将打开一个新窗口。我需要在新窗口上填充一些数据,然后单击保存按钮。单击保存按钮后,该窗口将自动关闭,并重定向到父窗口,父窗口将被刷新以显示在新窗口上添加的数据。但在重定向期间,它无法切换回父窗口,并抛出安全违规错误。 我正在使