Skip to content

Instantly share code, notes, and snippets.

Created January 4, 2013 14:54
Show Gist options
  • Save anonymous/4453113 to your computer and use it in GitHub Desktop.
Save anonymous/4453113 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA.Selenium.Interactions;
using OpenQA.Selenium.Interactions.Internal;
using MbUnit.Framework;
using AutomationFramework.Application.Selenium.Controllers;
namespace AutomationFramework.Application.Selenium.Objects
{
class Objects : Controllers.BaseApplication
{
protected readonly new static IWebDriver driver;
protected readonly new static IWebElement objectName;
public static IWebElement Object1(IWebElement objectName)
{
objectName = driver.FindElement(By.Id("txtMyData"));
return objectName;
}
//If multiple object repository items are used will this confuse the compiler because IWebElment objectName is being used as a return statement for each object?
public static IWebElement Object2(IWebElement objectName)
{
objectName = driver.FindElement(By.Id("txtMyData"));
return objectName;
}
//Proper way?
public static IWebElement object2CSS()
{
IWebElement adminCheckBox = driver.FindElement(By.CssSelector("td:contains('Nash')"));
return adminCheckBox;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using OpenQA.Selenium;
using OpenQA;
using AutomationFramework.Application.Selenium.Controllers;
namespace AutomationFramework.Application.Selenium.Controllers
{
public class RadioButton : BaseObject
{
public new IWebElement objectName { get; set; }
//private IWebElement RadioButtonTag;
public RadioButton(IWebElement objectName) : base(objectName)
{
this.objectName = objectName;
}
public static void SelectRadioButtons(IWebElement objectName, string element)
{
IWebElement selectBox = objectName.FindElement(By.Id(element));
selectBox.SendKeys(Keys.Return);
}
//hard to clear Radiobuttons without Javascript
/*public static void ClearRadioBoutotns(IWebElement objectName, string element)
{
IWebElement selectBox = objectName.FindElement(By.Id(element));
selectBox.c
}*/
public IList<IWebElement> RadioButtonListCss(string cssName)
{
IList<IWebElement> radioBtnList = objectName.FindElements(By.CssSelector(cssName));
return radioBtnList;
}
public void Select()
{
if (!objectName.Selected)
{
objectName.Click();
}
}
public bool Checked(IWebElement objectName)
{
if (!objectName.Selected)
{
return false;
}
return true;
}
//Returns a specific RadioButton with the associated indexx element declared within the parameter
public string IndexList(IWebDriver driver, string objectID, string indexx)
{
IWebElement clickIndexList;
string IndexList = string.Empty;
IndexList = driver.FindElements(By.CssSelector("css=ul#" + objectID + "li:nth-of-type(" + indexx + ")")).ToString();
return IndexList;
}
//Clicks a RadioButton Element from a list with a unique indexx number
/*public void ClickIndexList(IWebDriver driver, string objectID, string indexx)
{
IList<IWebElement> clickIndexList = driver.FindElements(By.CssSelector("css=ul#" + objectID + "li:nth-of-type(" + indexx + ")"));
clickIndexList[0].Click();
}*/
public IWebElement InnerText(IWebDriver driver, string innerText)
{
IList<IWebElement> objectName = driver.FindElements(By.CssSelector("css=a:contains('" + innerText + "')"));
return objectName[0];
}
//Deprecated Xpath
/*public void NextSibling(IWebDriver driver, IWebElement objectName, string objectID)
{
objectName = driver.FindElements(By.XPath("//*[@id='" + objectID + "']/following-sibling::span[@class='error']"));
}*/
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment