//When I want to do a mouse gesture, I can build it as such
var builder = new OpenQA.Selenium.Interactions.Actions(Driver);
IAction signInButton = builder.MoveToElement(Driver.FindElement(By. (SignInButton)))
.Click(Driver.FindElement(By.CssSelector(SignInButton)))
.Release(Driver.FindElement(By.CssSelector(SignInButton)))
.Build();
signInButton.Perform();
//If I cannot click on an object, even when it is enabled
if (Assert.IsTrue(SignInButton.Enabled))
{SignInButton.Click();}
else { Thread.Sleep(100);
SignInButton.Click();}
// I should do a submit.
if (Assert.IsTrue(SignInButton.Enabled))
{SignInButton.Submit();}
else { Thread.Sleep(100);
SignInButton.Submit();}
//make driver wait by default for async controls. note that controls must have a specified id. This maybe could be changed to take an IWebElement type
public void waitForItemById(string id)
{
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Id(id));
});
}
//nice switch to allow you to dynamically allocate the browser specific driver
public string BrowserType = "FF";
private string _iEDriverPath = AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\..\\..\\..\\Libraries\\IEDriverServer_x64\\";
public void GetDriver()
{
switch (BrowserType)
{
case "FF":
FirefoxProfile fp = new FirefoxProfile();
fp.EnableNativeEvents = false;
Driver = new FirefoxDriver();
break;
case "IE":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
Driver = new InternetExplorerDriver(_iEDriverPath, options);
break;
case "CH":
Driver = new ChromeDriver();
break;
}
//Nice XPath to find one of several values on a page where the indistinct value you want is nested after a distinct element.
//td[text() = 'Product 1']/following-sibling::td/a[
text() = 'View Download']
var builder = new OpenQA.Selenium.Interactions.Actions(Driver);
IAction signInButton = builder.MoveToElement(Driver.FindElement(By. (SignInButton)))
.Click(Driver.FindElement(By.CssSelector(SignInButton)))
.Release(Driver.FindElement(By.CssSelector(SignInButton)))
.Build();
signInButton.Perform();
//If I cannot click on an object, even when it is enabled
if (Assert.IsTrue(SignInButton.Enabled))
{SignInButton.Click();}
else { Thread.Sleep(100);
SignInButton.Click();}
// I should do a submit.
if (Assert.IsTrue(SignInButton.Enabled))
{SignInButton.Submit();}
else { Thread.Sleep(100);
SignInButton.Submit();}
//make driver wait by default for async controls. note that controls must have a specified id. This maybe could be changed to take an IWebElement type
public void waitForItemById(string id)
{
WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));
IWebElement myDynamicElement = wait.Until<IWebElement>((d) =>
{
return d.FindElement(By.Id(id));
});
}
//nice switch to allow you to dynamically allocate the browser specific driver
public string BrowserType = "FF";
private string _iEDriverPath = AppDomain.CurrentDomain.BaseDirectory + "\\..\\..\\..\\..\\..\\Libraries\\IEDriverServer_x64\\";
public void GetDriver()
{
switch (BrowserType)
{
case "FF":
FirefoxProfile fp = new FirefoxProfile();
fp.EnableNativeEvents = false;
Driver = new FirefoxDriver();
break;
case "IE":
var options = new InternetExplorerOptions();
options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
Driver = new InternetExplorerDriver(_iEDriverPath, options);
break;
case "CH":
Driver = new ChromeDriver();
break;
}
//Nice XPath to find one of several values on a page where the indistinct value you want is nested after a distinct element.
//td[text() = 'Product 1']/following-sibling::td/a[
- show quoted text -
No comments:
Post a Comment