Handling Frames in Selenium



using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;

namespace Selenium_Demo
{
public class HandlingFrames
{
public IWebDriver dr;
[SetUp]
public void Setup()
{
  Console.WriteLine("I am from setup method");
  dr = new ChromeDriver(@"C:\Users\userid\Desktop");  //path of your chrome driver
}
    [Test]
    public void VerifyHandlingFrames()
    {
        dr.Navigate().GoToUrl("https://demo.guru99.com/test/guru99home/");
        IWebElement elementFrame =     
        dr.FindElement(By.XPath("//iframe[@name='a077aa5e']"));
        dr.SwitchTo().Frame(elementFrame);
        IWebElement imgJmeter = 
        dr.FindElement(By.XPath("//a[@href='http://www.guru99.com/live-selenium-
        project.html']"));
        imgJmeter.Click();
    }
}
}

Tags:
Leave a comment

Your email address will not be published. Required fields are marked *

Subscribe now

Receive weekly newsletter with educational materials, new courses, most popular posts, popular books and much more!