org.openqa.selenium.WebDriver.Navigation Java Examples

The following examples show how to use org.openqa.selenium.WebDriver.Navigation. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DelegatingWebDriverTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testNavigate()
{
    Navigation navigation = Mockito.mock(Navigation.class);
    when(wrappedDriver.navigate()).thenReturn(navigation);
    assertEquals(navigation, delegatingWebDriver.navigate());
}
 
Example #2
Source File: WindowsActionsTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@Test
void testCloseAllWindowsExceptOneMobile()
{
    WebDriver webDriver = mock(WebDriver.class);
    when(webDriverProvider.get()).thenReturn(webDriver);
    when(webDriverManager.isAndroid()).thenReturn(true);
    Set<String> windows = new LinkedHashSet<>(List.of(WINDOW1, WINDOW2));
    TargetLocator targetLocator = mock(TargetLocator.class);
    when(webDriver.getWindowHandles()).thenReturn(windows);
    when(webDriver.switchTo()).thenReturn(targetLocator);
    Navigation navigation = mock(Navigation.class);
    when(webDriver.navigate()).thenReturn(navigation);
    windowsActions.closeAllWindowsExceptOne();
    verify(navigation, times(2)).back();
}
 
Example #3
Source File: SeleniumNavigationStepsTest.java    From senbot with MIT License 5 votes vote down vote up
@Test
public void testPageRefresh() {
    final WebDriver mockDriver = mock(WebDriver.class);
    Navigation navigation = mock(Navigation.class);
    when(mockDriver.navigate()).thenReturn(navigation);

    MockSeleniumNavigationStepDefinitions navigationSteps = new MockSeleniumNavigationStepDefinitions(mockDriver);

    navigationSteps.pageRefresh();

    verify(navigation, times(1)).refresh();
}
 
Example #4
Source File: EventFiringWebDriverTest.java    From selenium with Apache License 2.0 5 votes vote down vote up
@Test
public void navigationEvents() {
  final WebDriver mockedDriver = mock(WebDriver.class);
  final Navigation mockedNavigation = mock(Navigation.class);

  when(mockedDriver.navigate()).thenReturn(mockedNavigation);

  WebDriverEventListener listener = mock(WebDriverEventListener.class);

  EventFiringWebDriver testedDriver = new EventFiringWebDriver(mockedDriver).register(listener);

  testedDriver.get("http://www.get.com");
  testedDriver.navigate().to("http://www.navigate-to.com");
  testedDriver.navigate().back();
  testedDriver.navigate().forward();
  testedDriver.navigate().refresh();

  InOrder order = Mockito.inOrder(mockedDriver, mockedNavigation, listener);
  order.verify(listener).beforeNavigateTo(eq("http://www.get.com"), any(WebDriver.class));
  order.verify(mockedDriver).get("http://www.get.com");
  order.verify(listener).afterNavigateTo(eq("http://www.get.com"), any(WebDriver.class));
  order.verify(mockedDriver).navigate();
  order.verify(listener).beforeNavigateTo(eq("http://www.navigate-to.com"), any(WebDriver.class));
  order.verify(mockedNavigation).to("http://www.navigate-to.com");
  order.verify(listener).afterNavigateTo(eq("http://www.navigate-to.com"), any(WebDriver.class));
  order.verify(mockedDriver).navigate();
  order.verify(listener).beforeNavigateBack(any(WebDriver.class));
  order.verify(mockedNavigation).back();
  order.verify(listener).afterNavigateBack(any(WebDriver.class));
  order.verify(mockedDriver).navigate();
  order.verify(listener).beforeNavigateForward(any(WebDriver.class));
  order.verify(mockedNavigation).forward();
  order.verify(listener).afterNavigateForward(any(WebDriver.class));
  order.verify(mockedDriver).navigate();
  order.verify(listener).beforeNavigateRefresh(any(WebDriver.class));
  order.verify(mockedNavigation).refresh();
  order.verify(listener).afterNavigateRefresh(any(WebDriver.class));
  verifyNoMoreInteractions(mockedDriver, mockedNavigation, listener);
}
 
Example #5
Source File: Browser.java    From aquality-selenium-java with Apache License 2.0 4 votes vote down vote up
private Navigation navigate() {
    return new BrowserNavigation(getDriver());
}
 
Example #6
Source File: WebDriverBrowserTest.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Test
public void testThatNavigatingBackInvokesCorrectWebDriverMethods() {
    Navigation navigation = mockNavigation();
    cut.navigateBackwards();
    verify(navigation).back();
}
 
Example #7
Source File: WebDriverBrowserTest.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Test
public void testThatNavigatingForwardsInvokesCorrectWebDriverMethods() {
    Navigation navigation = mockNavigation();
    cut.navigateForwards();
    verify(navigation).forward();
}
 
Example #8
Source File: WebDriverBrowserTest.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
@Test
public void testThatRefreshingInvokesCorrectWebDriverMethods() {
    Navigation navigation = mockNavigation();
    cut.refresh();
    verify(navigation).refresh();
}
 
Example #9
Source File: WebDriverBrowserTest.java    From webtester-core with Apache License 2.0 4 votes vote down vote up
private Navigation mockNavigation() {
    Navigation navigation = mock(Navigation.class);
    doReturn(navigation).when(webDriver).navigate();
    return navigation;
}
 
Example #10
Source File: AcceptanceTestBase.java    From mamute with Apache License 2.0 4 votes vote down vote up
protected Navigation browser() {
	return driver.navigate();
}