@Before public void setUp() throws Exception { MockLogAppender.setupLogging(true, "DEBUG"); // Google Chrome // System.setProperty("webdriver.chrome.driver", "/Users/ranger/Downloads/chromedriver"); // WebDriver driver = new ChromeDriver(); // Selenium remote server // DesiredCapabilities capability = DesiredCapabilities.firefox(); // WebDriver driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), capability); // Firefox WebDriver driver = new FirefoxDriver(); String baseUrl = "http://localhost:8980/"; selenium = new WebDriverBackedSelenium(driver, baseUrl); selenium.open("/opennms/login.jsp"); selenium.type("name=j_username", "admin"); selenium.type("name=j_password", "admin"); selenium.click("name=Login"); waitForPageToLoad(); }
protected WebDriverBackedSeleniumDriver(WebDriver wd, String url) { super(); setSiteUrl(url); Selenium wdbs = new WebDriverBackedSelenium(wd, url); setSelenium(wdbs); startSelenium(); }
@BeforeClass public static void setup() throws Exception { LOG.debug("Starting Jetty"); server = new Server(0); String url = setupJetty(); LOG.info("Jetty started on {}", url); driver = new FirefoxDriver(); LOG.debug("Starting selenium"); selenium = new WebDriverBackedSelenium(driver, url); driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); }
/** * @param driver * @param locator */ public void hoverMouseOn(WebDriver driver, String locator) { WebDriverBackedSelenium selenium = new WebDriverBackedSelenium(driver, driver.getCurrentUrl()); selenium.mouseOver(locator); }
public OwnerPage(WebDriverBackedSelenium selenium) { super("Owners", selenium, HomePage.PAGE_TITLE); if (!selenium.getHtmlSource().contains("Owner Information")) { String msg = format("Owner Information page has not been loaded from [%s]", selenium.getLocation()); throw new NotCorrectPageException(msg); } }
public AddOwnerPage(WebDriverBackedSelenium selenium) { super("Add Owner", selenium, HomePage.PAGE_TITLE); if (!selenium.getHtmlSource().contains(" New Owner")) { String msg = format("Add Owner page has not been loaded from [%s]", selenium.getLocation()); throw new NotCorrectPageException(msg); } }
public FindOwnersPage(WebDriverBackedSelenium selenium) { super("Find Owners", selenium, HomePage.PAGE_TITLE); if (!selenium.getHtmlSource().contains("Find Owners")) { String msg = format("Find Owners page has not been loaded from [%s]", selenium.getLocation()); throw new NotCorrectPageException(msg); } }
public HomePage(WebDriverBackedSelenium selenium) { super("Home", selenium, PAGE_TITLE); if (!selenium.getHtmlSource().contains("Welcome")) { String msg = format("Home page has not been loaded from [%s]", selenium.getLocation()); throw new NotCorrectPageException(msg); } }
public BasePage(String internalPageName, WebDriverBackedSelenium selenium, String expectedPageText) { this.internalPageName = internalPageName; this.selenium = selenium; String html = getHtml(); if (!html.contains(expectedPageText)) { String msg = format("Page body (%s) does not contain expected text (%s), current page is: %s", html, expectedPageText, selenium.getLocation()); throw new NotCorrectPageException(msg); } }
public BrowserEmulator() { setupBrowserCoreType(GlobalSettings.browserCoreType); browser = new WebDriverBackedSelenium(browserCore, "https://github.com/"); javaScriptExecutor = (JavascriptExecutor) browserCore; logger.info("Started BrowserEmulator"); }
/** * 获取 WebDriverBackedSelenium 实例 * @return */ public WebDriverBackedSelenium getBrowser() { return browser; }