https://github.com/andreaskarz/funkybdd.sxs.selenium.webelement
Extensions for the Selenium IWebElement. Integrates properties and methods that are always needed. Supports the POM and APOM principles.
https://github.com/andreaskarz/funkybdd.sxs.selenium.webelement
apom automated-testing bdd bdd-framework extension extension-methods iwebdriver iwebelement pom selenium selenium-csharp selenium-webdriver sxs testing testing-framework
Last synced: about 1 month ago
JSON representation
Extensions for the Selenium IWebElement. Integrates properties and methods that are always needed. Supports the POM and APOM principles.
- Host: GitHub
- URL: https://github.com/andreaskarz/funkybdd.sxs.selenium.webelement
- Owner: AndreasKarz
- License: mit
- Created: 2019-08-14T07:03:12.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-09-10T09:03:29.000Z (over 5 years ago)
- Last Synced: 2025-02-05T22:59:07.173Z (3 months ago)
- Topics: apom, automated-testing, bdd, bdd-framework, extension, extension-methods, iwebdriver, iwebelement, pom, selenium, selenium-csharp, selenium-webdriver, sxs, testing, testing-framework
- Language: C#
- Size: 27.3 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# FunkyBDD.SxS.Selenium.WebElement
Extensions for the **Selenium IWebElement** with missed methods and properties.```c#
using OpenQA.Selenium;
using OpenQA.Selenium.Firefox;
using System;namespace FunkyBDD.SxS.Selenium.WebElement.Test
{
class Program
{
public static IWebDriver Driver;static void Main(string[] args)
{
Driver = new FirefoxDriver("./");
Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(120);
Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
Driver.Navigate().GoToUrl("https://www.swisslife.ch/de/private.html/");
var parent = Driver.FindElement(By.TagName("body"));
/* Sometimes you need the wrapped driver of the parent */
IWebDriver wrappedDriver = parent.GetDriver();
Console.WriteLine($"The currenttitle '{wrappedDriver.Title}'");/* Find the element inside the parent element safe without exception */
var labelToScroll = parent.FindElementFirstOrDefault(By.CssSelector("h3.a-heading--style-italic"), 5);
Console.WriteLine(labelToScroll.Text);/* Test ScrollTo() */
if (labelToScroll != null) {
labelToScroll.ScrollTo();
Console.WriteLine("Scrolled to this label");
}
/* Find all elementS inside the parent safe without exception */
var labels = parent.FindElementsOrDefault(By.TagName("h3"));
Console.WriteLine($"{labels.Count} labels of h3 found");/* Real example, accept the disclaimer, if it exists */
var disclaimerButton = parent.FindElementFirstOrDefault(By.CssSelector("[class*='cookie-disclaimer']>button"), 1);
if(disclaimerButton != null)
{
disclaimerButton.Click();
}/* Search a not existing element inside the parent, should by null */
var notFound = parent.FindElementFirstOrDefault(By.TagName("h99"), 5);
Console.WriteLine($"Element h99 is {notFound}");Console.WriteLine(" ");
Console.WriteLine("Press enter to terminate...");
Console.ReadLine();Driver.Close();
Driver.Dispose();
Driver.Quit();
}
}
}```
You will find a learning project with examples based on this package on [GitHub](https://github.com/AndreasKarz/AutomatedTestingWorkshop)