Professional Documents
Culture Documents
Day1
– Introduction to Selenium IWebDriver
– Instantiating Selenium IWebDriver
– IWebDriver methods
– Launch the application
– Control the browser
– Work with browser's Object
– Locating Object with Xpath
– Locating Object with cssSelector
Day2
– IWebDriver Wait Time
Implicit Wait
Explicit Wait
Fluent Wait
– Action Class
– Handling Ajax Call using WebDriver
– Dynamic WebTable
– Taking Screen shot
– Nunit
Annotation
Priorities
Day 3:
C# Introducation
C# program window
C# Terms & Folders
OOPs (Object Oriented Programming System)
Object and Class
Constructor & Desctructor
Some useful Keywords:
Access Modifiers
Day 1
Selenium Introduction
Firefox extension
https://addons.mozilla.org/en-US/firefox/addon/selenium-ide/
Easy record and replay
Debug and set breakpoints
Save tests in HTML, WebDriver
and other formats.
Selenium saves all information
in an HTML table format
Each record consists of:
Command – tells Selenium what to do (e.g. “open”, “type”,
“click”, “verifyText”)
Target – tells Selenium which HTML element a command refers
to (e.g. textbox, header, table)
Value – used for any command that might need a value of some
kind (e.g. type something into a textbox)
click/clickAndWait 1 Clicks on a
specified
element.
verifyTextPresent 1 Checks if a
certain text is
found within the
page.
verifyElementPresent 1 Checks the
presence of a
certain element.
Firefox Browser
IWebDriver driver = new FirefoxDriver(@"C:\Path for
geckodriver exe\");
Chrome Browser
IWebDriver driver = new ChromeDriver(@"C:\Path for chrome
exe\");
Internet Browser
IWebDriver driver = new InternetExplorerDriver(@"C:\Path for IE
exe\");
Not the Selenium executable for above drivers are available in
seleniumhq website mentioned in next slide. Download the
executable and unzip it.
Downloading Browser executable
Download browse's executable from below link for Firefox,
Chrome, IE:
Link: http://www.seleniumhq.org/download/
WebDriver methods to -
By Id
driver.FindElement( By.Id("coolestWidgetEvah") );
By Name
By Xpath
HTML Page :
<html>
<input type="text" name="example" />
<input type="text" name="other" />
</html>
WebDriver:
driver.FindElements( By.Xpath("//input") );
• Example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NUnit.Framework;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using OpenQA.Selenium.Firefox;
using OpenQA.Selenium.IE;
namespace SeleniumTesting
{
[TestFixture]
class SeleniumIE
{
IWebDriver driver;
[SetUp]
public void StartBrowser()
{
driver = new
InternetExplorerDriver(@"C:\Users\Hunza\SeleniumCsharp\Seleni
umAutomation\");
}
[Test]
public void Test()
{
driver.Manage().Window.Maximize();
driver.Manage().Timeouts().PageLoad =
TimeSpan.FromSeconds(25);
driver.Url = "http://www.google.co.in";
IWebElement field= driver.FindElement(By.Id("lst-ib"));
field.Clear();
field.SendKeys("Seleniumhq");
IWebElement fieldButton =
driver.FindElement(By.Name("btnK"));
fieldButton.Click();
}
[TearDown]
public void CloseBrowser()
{
driver.Close();
}
}
}
driver.FindElement(By.TagName("button")).GetAttribute("cla
ss")
TagName() - get the html tag name (input/button/select)
driver.FindElement(By.Id("inp1")).TagName()
Displayed()/ Enabled()/ Selected() - verify the
displayed/enabled/selected status of html tags