-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWIndowHandles
46 lines (38 loc) · 1.37 KB
/
WIndowHandles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Support.UI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AdvanceSelenium
{
public class ChildTab
{
IWebDriver driver;
[SetUp]
public void SetUp()
{
driver = new ChromeDriver();
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
driver.Navigate().GoToUrl("https://rahulshettyacademy.com/loginpagePractise/");
}
[Test]
public void ChildTabMethod()
{
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.ClassName("blinkingText")));
driver.FindElement(By.ClassName("blinkingText")).Click();
Assert.That(driver.WindowHandles.Count,Is.EqualTo(2));
string windownames = driver.WindowHandles[1];
driver.SwitchTo().Window(windownames);
string title = driver.FindElement(By.CssSelector("h1")).Text;
Console.WriteLine(title);
driver.SwitchTo().Window(driver.WindowHandles[0]);
Console.WriteLine(driver.Title);
}
}
}