-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
add csharpwindowscommands #1774
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
Changes from 5 commits
4e8931a
64661ee
a0b622c
9e0c15b
18e6c3b
e6dda92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,49 @@ | ||
using System; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
using OpenQA.Selenium; | ||
using OpenQA.Selenium.Chrome; | ||
|
||
namespace SeleniumDocs.Interactions | ||
{ | ||
[TestClass] | ||
public class WindowsTest : BaseTest | ||
public class WindowsTest | ||
{ | ||
[TestMethod] | ||
public void TestWindowCommands() | ||
{ | ||
WebDriver driver = new ChromeDriver(); | ||
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromMilliseconds(500); | ||
|
||
// Navigate to Url | ||
driver.Url="https://www.selenium.dev/selenium/web/window_switching_tests/page_with_frame.html"; | ||
//fetch handle of this | ||
String currHandle = driver.CurrentWindowHandle; | ||
Assert.IsNotNull(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 | ||
IList<string> windowHandles = new List<string>(driver.WindowHandles); | ||
Check failure on line 26 in examples/dotnet/SeleniumDocs/Interactions/WindowsTest.cs
|
||
driver.SwitchTo().Window(windowHandles[1]); | ||
//assert on title of new window | ||
String title = driver.Title; | ||
Assert.AreEqual("Simple Page", title); | ||
|
||
//closing current window | ||
driver.Close(); | ||
//Switch back to the old tab or window | ||
driver.SwitchTo().Window(windowHandles[0]); | ||
|
||
//Opens a new tab and switches to new tab | ||
driver.SwitchTo().NewWindow(WindowType.Tab); | ||
Assert.AreEqual("", driver.Title); | ||
|
||
//Opens a new window and switches to new window | ||
driver.SwitchTo().NewWindow(WindowType.Window); | ||
Assert.AreEqual("", driver.Title); | ||
|
||
//quitting driver | ||
driver.Quit(); //close all windows | ||
} | ||
} | ||
} |
Uh oh!
There was an error while loading. Please reload this page.