string IWebDriver.Url { get; set;}
/* Selenium Webdriver command for URL*/ String URL; driver = new ChromeDriver(); /* Set Operation */ driver.Url = "https://www.lambdatest.com"; /* Get Operation */ URL = driver.Url;
string IWebDriver.Title{get;}
/* Selenium Webdriver command for getting title */ String page_title; driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; page_title = driver.Title;
string IWebDriver.PageSource{get;}
/* Selenium Webdriver command for getting page source*/ String page_source; driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; page_source = driver.PageSource;
void IWebDriver.Quit()
/* Selenium Webdriver command for URL*/ driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); /* Quit the window for this NUnit tutorial*/ driver.Quit();
void IWebDriver.Close()
/* Selenium Webdriver command for Closing window*/ driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; driver.Close();
INavigation IWebDriver.Navigate()
void INavigation.Back()
driver.Navigate().Back();
void INavigation.Forward()
driver.Navigate().Forward();
void INavigation.GoToUrl(string url)
driver.Navigate().GoToUrl(“https://www.lambdatest.com")
void INavigation.Refresh()
driver.Navigate().Refresh();
void IWebElement.Click()
/*Selenium Webdriver command for click*/ driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id="navbarSupportedContent"]/ul/li[6]/a")); web_element.Click();
Bool IWebElement.Enabled{get;}
/*Selenium Webdriver command to check whether a particular web element is enabled */ driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id="navbarSupportedContent"]/ul/li[6]/a")); Boolean element_enabled = web_element.Enabled;
Bool IWebElement.Displayed{get;}
/*Selenium Webdriver command to check whether a particular web element is displayed */ driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id="navbarSupportedContent"]/ul/li[6]/a")); Boolean element_enabled = web_element.Displayed;
void IWebElement.Clear()
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Email address text box on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='useremail']"); web_element.Clear();
void IWebElement.SendKeys(string text)
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Email address text box on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='useremail']"); web_element.SendKeys("test@email.com");
string IWebElement.GetAttribute(string attributename)
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Email address text box on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='navbarSupportedContent']/ul/li[6]/a")); String titleValue = web_element.GetAttribute("class");
string IWebElement.GetCssValue(string propertyname)
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='navbarSupportedContent']/ul/li[6]/a")); /* returns #000000 */ String cssvalue = web_element.GetCssValue("background-color");
void IWebElement.Submit()
driver = new ChromeDriver(); driver.Url = "https://accounts.lambdatest.com/login"; /* The Xpath of the Login Button on which is of the type submit */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='app']/section/form/div/div/button")); web_element.Submit();
string IWebElement.Text{get;}
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='navbarSupportedContent']/ul/li[6]/a")); String text_value = web_element.Text;
string IWebElement.TagName{get;}
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* The Xpath of the Login Button on LambdaTest homepage */ IWebElement web_element = driver.FindElement(By.XPath("//*[@id='navbarSupportedContent']/ul/li[6]/a")); String tag_name = web_element.TagName;
bool IWebElement.Selected{get;}
driver = new ChromeDriver(); driver.Url = "https://lambdatest.github.io/sample-todo-app/"; IWebElement web_element = driver.FindElement(By.XPath("/html/body/div/div/div/ul/li[1]/input")); bool selected_status = web_element.Selected;
Size IWebElement.Size{get;}
driver = new ChromeDriver(); driver.Url = "https://www.lambdatest.com"; /* Get the window size */ Console.WriteLine(driver.Manage().Window.Size);
void SelectElement.SelectByIndex(int index)
driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.SelectByIndex(1);
void SelectElement.DeselectByIndex(int index)
driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.DeselectByIndex(1);
void SelectElement.SelectByText(string text, [bool partialMatch = false])
driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.SelectByText("on IE6");
void SelectElement.DeselectByText(string text)
driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.DeselectByText("on IE6");
void SelectElement.SelectByValue(string value)
driver = new ChromeDriver(); driver.Url = "http://www.tizag.com/phpT/examples/formex.php"; IWebElement element = driver.FindElement(By.XPath("//*[@id='examp']/form/select[1]")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.SelectByValue("HighSchool");
void SelectElement.DeselectByValue(string value)
driver = new ChromeDriver(); driver.Url = "http://www.tizag.com/phpT/examples/formex.php"; IWebElement element = driver.FindElement(By.XPath("//*[@id='examp']/form/select[1]")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.DeselectByValue("HighSchool");
void SelectElement.DeselectAll()
driver = new ChromeDriver(); driver.Url = "http://www.example-site.com"; IWebElement element = driver.FindElement(By.XPath("x-path")); SelectElement select_elem = new SelectElement(element); select_elem.DeselectAll();
bool SelectElement.IsMultiple{get;}
driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); bool is_multi_select = select_elem.IsMultiple; Console.WriteLine("Multi Select {0}", is_multi_select);
IList<IWebElement> SelectElement.Options{ get; }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Drawing; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Support.UI; namespace NUnitDemo { class NUnit_Demo { IWebDriver driver; [Test] public void cssDemo() { driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.SelectByText("on IE6"); /* List will contain details of all the options */ IList<IWebElement> avail_options = select_elem.Options; int ListSize = avail_options.Count; for (int loop_var = 0; loop_var < ListSize; loop_var++) { String text_value = select_elem.Options.ElementAt(loop_var).Text; System.Diagnostics.Debug.WriteLine("Selected item is " + text_value); } } driver.Close(); } }
IList<IWebElement> AllSelectedOptions { get; }
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using System.Drawing; using NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Support.UI; namespace NUnitDemo { class NUnit_Demo { IWebDriver driver; [Test] public void cssDemo() { driver = new ChromeDriver(); driver.Url = "http://demos.dojotoolkit.org/dijit/tests/test_Menu.html"; IWebElement element = driver.FindElement(By.XPath("//select[@aria-label='select']")); SelectElement select_elem = new SelectElement(element); /* Sleep for 4 seconds after page is displayed */ System.Threading.Thread.Sleep(4000); select_elem.SelectByText("on IE6"); /* List will contain details of all the options */ IList<IWebElement> avail_options = select_elem.AllSelectedOptions; int ListSize = avail_options.Count; System.Diagnostics.Debug.WriteLine("List size is " + ListSize); for (int loop_var = 0; loop_var < ListSize; loop_var++) { String text_value = avail_options.ElementAt(loop_var).Text; System.Diagnostics.Debug.WriteLine("Selected item is " + text_value); } } driver.Close(); } }