Thursday, 31 January 2019

Handle Multiple Window in Selenium webdriver c#

Handle Multiple Browser tab Using C#

Here , I am going to show you how to handle multiple browser tab and switch browser tabs using selenium web driver c#.



using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.Html5;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using TestApp.Performance;

using System.Windows.Forms;

namespace TestApp
{
    class Program
    {
        static void Main(string[] args)
        {
            IWebDriver _driver = new FirefoxDriver();
            _driver.Navigate().GoToUrl("https://www.google.com");

            ReadOnlyCollection<string> WindowHandles = _driver.WindowHandles;
            foreach (string item in WindowHandles)
            {
                _driver.SwitchTo().Window(item);
                string browserTitle = _driver.Title;
                string browserPageSource = _driver.PageSource;
                string browserURL = _driver.Url;
            }
            Thread.Sleep(2000);
        }
  
    }

}

Single Test case Run parallel with TestNG Framework

1) Create TestNG class. package com.software.testing; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome....