public static XPath ( string xpathToFind ) : |
||
xpathToFind | string | The XPath query to use. |
return |
public static By XPath(string xpathToFind)
{
if (xpathToFind == null)
{
throw new ArgumentNullException("xpathToFind", "Cannot find elements when the XPath expression is null.");
}
By by = new By();
by.findElementMethod = (ISearchContext context) => ((IFindsByXPath)context).FindElementByXPath(xpathToFind);
by.findElementsMethod =
(ISearchContext context) => ((IFindsByXPath)context).FindElementsByXPath(xpathToFind);
by.description = "By.XPath: " + xpathToFind;
return by;
}
public void BookIntervalFromNotBooked(string courtNumber) { var startTimeHour = Convert.ToInt32(DateTime.Now.ToString("HH")); startTimeHour = startTimeHour + 1; var startTimeMinutes = DateTime.Now.ToString("mm"); var startTimeSeconds = DateTime.Now.ToString("ss"); Console.WriteLine(startTimeHour + ":" + startTimeMinutes + ":" + startTimeSeconds); switch (courtNumber) { case "Court1": driver.FindElement(By.XPath( "//*[@id='book-by-date-view']/div/div[2]/div[2]/ul/li[1]/div/div/div[2]/div/div[" + startTimeHour + "]")).Click(); break; case "Court2": driver.FindElement(By.XPath( "//*[@id='book-by-date-view']/div/div[2]/div[2]/ul/li[2]/div/div/div[2]/div/div[" + startTimeHour + "]")).Click(); break; case "Court3": driver.FindElement(By.XPath( "//*[@id='book-by-date-view']/div/div[2]/div[2]/ul/li[3]/div/div/div[2]/div/div[" + startTimeHour + "]")).Click(); break; } }