Tag: remotewebdriver

维护并重用现有的webdriver浏览器实例 – java

基本上每次我从eclipse运行我的java代码时,webdriver都会启动一个新的ie浏览器并在大多数情况下成功执行我的测试。 但是,我有很多测试要运行,webdriver每次启动一个新的浏览器会话都很痛苦。 我需要一种方法来重用以前打开过的浏览器; 所以webdriver会打开,即第一次,然后第二次,我运行我的eclipse程序,我希望它只是拿起以前的浏览器实例并继续在同一个实例上运行我的测试。 这样,我每次运行程序时都不会启动新的浏览器会话。 假设你有100个测试要在eclipse中运行,你点击那个运行按钮然后它们全部运行,然后在大约第87次测试时你得到一个错误。 然后你回到eclipse,修复那个错误,但是你必须从头再次重新运行所有100个测试。 在第87次测试中修复错误,然后从第87次测试恢复执行,而不是从头开始重新执行所有测试,即从测试0一直到100,这将是很好的。希望,我很清楚得到你们的帮助,谢谢顺便说一下。 以下是我尝试维护和重用webdriver Internet Explorer浏览器实例的尝试: public class demo extends RemoteWebDriver { public static WebDriver driver; public Selenium selenium; public WebDriverWait wait; public String propertyFile; String getSessionId; public demo() { // constructor DesiredCapabilities ieCapabilities = DesiredCapabilities .internetExplorer(); ieCapabilities .setCapability( InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true); driver = new InternetExplorerDriver(ieCapabilities); this.saveSessionIdToSomeStorage(getSessionId); this.startSession(ieCapabilities); driver.manage().window().maximize(); } @Override […]

参数化selenium测试与TestNG并行

首先,对不起我的英语,它不是那么完美:) 所以我面临以下问题:我正在尝试使用Selenium Grid和TestNg在不同的浏览器中运行并行测试,并且我在@BeforeTest方法中传递参数。 我的问题是,当每个测试都被初始化时,似乎他们将使用最后一个测试的参数。 因此,在此示例中,当我运行测试时,它将打开两个Chrome,而不是一个Firefox和一个Chrome。 (browser.getDriver()方法返回一个RemoteWebDriver) testng.xml文件: AbstractTest类: public class SeleniumTest { private static List webDriverPool = Collections.synchronizedList(new ArrayList()); private static ThreadLocal driverThread; public static BrowserSetup browser; @Parameters({ “browserName”, “browserVersion”, “platform”}) @BeforeTest() public static void beforeTest(String browserName, @Optional(“none”) String browserVersion, String platform) throws WrongBrowserException, WrongPlatformException { final BrowserSetup browser = new BrowserSetup(browserName, browserVersion, platform); driverThread […]