List of usage examples for org.openqa.selenium WebDriver switchTo
TargetLocator switchTo();
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldSwitchDriverToAlertIfCurrentTargetIsNoLongerAlertAndIsDifferentThanOriginalTarget() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); when(mockLocator.alert()).thenReturn(mock(Alert.class)); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.alert();//from ww w. ja v a 2 s .c o m targetLocator.window("different"); targetLocator.alert(); verify(mockLocator, times(2)).alert(); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldKeepTrackOfPreviousWebDriverTargetIfAlertIsCurrentTarget() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); when(mockLocator.alert()).thenReturn(mock(Alert.class)); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.alert();/* w ww. ja va 2 s. c o m*/ targetLocator.frame("frame"); assertEquals(WebDriverTargets.frame(WebDriverTargets.window("test"), "frame"), targetLocator.getCurrentTarget()); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldSwitchDriverToDefaultContent() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.defaultContent();//from w w w. j ava 2s.c o m verify(mockLocator).defaultContent(); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldNotSwitchDriverIfNewTargetAndPreviousTargetAreDefaultContent() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.defaultContent();/*from ww w . j a v a 2 s. co m*/ targetLocator.defaultContent(); verify(mockLocator, times(1)).defaultContent(); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldSwitchDriverBackToDefaultContentIfWasSwitchedAwayFrom() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.defaultContent();// ww w . j a v a2 s. com targetLocator.window("test"); targetLocator.defaultContent(); verify(mockLocator, times(2)).defaultContent(); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldSwitchToActiveElement() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); WebElement activeElement = mock(WebElement.class); when(mockDriver.switchTo()).thenReturn(mockLocator); when(mockLocator.activeElement()).thenReturn(activeElement); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); assertSame(activeElement, targetLocator.activeElement()); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldNotCacheActiveElement() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); WebElement firstActiveElement = mock(WebElement.class); WebElement secondActiveElement = mock(WebElement.class); when(mockDriver.switchTo()).thenReturn(mockLocator); when(mockLocator.activeElement()).thenReturn(firstActiveElement, secondActiveElement); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); assertSame(firstActiveElement, targetLocator.activeElement()); assertSame(secondActiveElement, targetLocator.activeElement()); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldKeepCurrentTargetUnchangedWhenActiveElementIsSwitchedTo() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.activeElement();//from w ww .j a v a2 s. c o m assertEquals(WebDriverTargets.window("test"), targetLocator.getCurrentTarget()); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldDetermineParentOfCurrentTarget() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator( WebDriverTargets.frame(WebDriverTargets.window("parent"), "frame"), mockDriver); targetLocator.parentFrame();//from w ww.j a va 2s . c o m assertEquals(WebDriverTargets.window("parent"), targetLocator.getCurrentTarget()); }
From source file:com.redhat.darcy.webdriver.internal.CachingTargetLocatorTest.java
License:Open Source License
@Test public void shouldNotSwitchTargetIfAttemptingToSwitchToParentOfTargetThatIsNotAFrame() { WebDriver mockDriver = mock(WebDriver.class); TargetLocator mockLocator = mock(TargetLocator.class); when(mockDriver.switchTo()).thenReturn(mockLocator); CachingTargetLocator targetLocator = new CachingTargetLocator(WebDriverTargets.window("test"), mockDriver); targetLocator.parentFrame();//from w w w. jav a2 s.c o m assertEquals(WebDriverTargets.window("test"), targetLocator.getCurrentTarget()); }