-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Added example code to windows and modified text #1754
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
048e7e7
added example code for windows and switched text order. modified some…
pallavigitwork 9a0da96
fixed tab pane hugo error
pallavigitwork 815374f
Merge branch 'trunk' into windowExampleDocs
harsha509 e4848b6
Merge branch 'trunk' into windowExampleDocs
harsha509 6bd1b54
Merge branch 'trunk' into windowExampleDocs
harsha509 8726be4
Merge branch 'trunk' into windowExampleDocs
harsha509 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
47 changes: 44 additions & 3 deletions
47
examples/java/src/test/java/dev/selenium/interactions/WindowsTest.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,48 @@ | ||
package dev.selenium.interactions; | ||
|
||
import dev.selenium.BaseTest; | ||
import org.openqa.selenium.*; | ||
import org.openqa.selenium.chrome.ChromeDriver; | ||
import java.time.Duration; | ||
import org.junit.jupiter.api.Test; | ||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
public class WindowsTest extends BaseTest { | ||
public class WindowsTest { | ||
|
||
} | ||
@Test | ||
public void windowsExampleCode() { | ||
|
||
WebDriver driver = new ChromeDriver(); | ||
driver.manage().timeouts().implicitlyWait(Duration.ofMillis(500)); | ||
// Navigate to Url | ||
driver.get("https://www.selenium.dev/selenium/web/window_switching_tests/page_with_frame.html"); | ||
//fetch handle of this | ||
String currHandle=driver.getWindowHandle(); | ||
assertNotNull(currHandle); | ||
|
||
//click on link to open a new window | ||
driver.findElement(By.linkText("Open new window")).click(); | ||
//fetch handles of all windows, there will be two, [0]- default, [1] - new window | ||
Object[] windowHandles=driver.getWindowHandles().toArray(); | ||
driver.switchTo().window((String) windowHandles[1]); | ||
//assert on title of new window | ||
String title=driver.getTitle(); | ||
assertEquals("Simple Page",title); | ||
|
||
//closing current window | ||
driver.close(); | ||
//Switch back to the old tab or window | ||
driver.switchTo().window((String) windowHandles[0]); | ||
|
||
//Opens a new tab and switches to new tab | ||
driver.switchTo().newWindow(WindowType.TAB); | ||
assertEquals("",driver.getTitle()); | ||
|
||
//Opens a new window and switches to new window | ||
driver.switchTo().newWindow(WindowType.WINDOW); | ||
assertEquals("",driver.getTitle()); | ||
|
||
//quitting driver | ||
driver.quit(); //close all windows | ||
|
||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.