This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const items = [ | |
{name:'Bike', price:100}, | |
{name:'TV', price:200}, | |
{name:'Album', price:10}, | |
{name:'Book',price:5}, | |
{name:'Phone',price:500}, | |
{name:'Computer',price:1000}, | |
{name:'Keyboard', price:25} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Not needed for value types like bool and int | |
//null reference check example. | |
//Good practice to use such reference checks | |
private void SetDependency(string rowIndex, string columnName, string dependency) | |
{ | |
if (rowIndex is null) throw new ArgumentNullException(nameof(rowIndex)); | |
if (columnName is null) throw new ArgumentNullException(nameof(columnName)); | |
if (dependency is null) throw new ArgumentNullException(nameof(dependency)); | |
.. | |
..} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
using OpenQA.Selenium; | |
using OpenQA.Selenium.Appium.Android; | |
using OpenQA.Selenium.Appium.iOS; | |
using OpenQA.Selenium.Chrome; | |
using OpenQA.Selenium.Edge; | |
using OpenQA.Selenium.Firefox; | |
using OpenQA.Selenium.Remote; | |
using OpenQA.Selenium.Support.Events; | |
using System; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class BasePage : Driver | |
{ | |
protected IWebElement LookUpElement(By locator) {} | |
protected IWebElement LookUpElements(By locator) {} | |
protected string[] GetTextsByLocator(By locator) {} | |
protected int GetCountOfElements(By locator) {} | |
protected int GetCountOfElementsUsingJS(string CssSelector) {} | |
protected string[] GetTextValuesByCssSelector(string CssSelector) {} | |
.. | |
.. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//input is a child of td having a col index of 0 | |
td[aria-colindex='0'] input | |
//Css selector using a pseudoelement :before :focus-within etc | |
//here we get the label having a pseudoelement focus-within | |
label:focus-within |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// <summary> | |
/// Gets list of strings defined by given CssSelector | |
/// </summary> | |
/// <param name="CssSelector">Css selector to identify the group of elements</param> | |
/// <returns>array of strings</returns> | |
protected string[] GetTextValuesByCssSelector(string CssSelector) | |
{ | |
if (CssSelector is null) throw new ArgumentNullException(nameof(CssSelector)); | |
object obj = ((IJavaScriptExecutor)this.GetDriver).ExecuteScript($"return Array.from(document.querySelectorAll(\"{CssSelector}\"),x=>x.value)"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// This method is useful when count can be 0 or is expected to be zero | |
/// </summary> | |
/// <param name="CssSelector"></param> | |
/// <returns>count of elements</returns> | |
protected int GetCountOfElementsUsingJS(string CssSelector) | |
{ | |
if (CssSelector is null) throw new ArgumentNullException(nameof(CssSelector)); | |
int count; | |
count = Convert.ToInt32(((IJavaScriptExecutor)this.GetDriver).ExecuteScript($"return document.querySelectorAll('{CssSelector}').length")); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Actions action = new Actions(webdriver); | |
WebElement we = webdriver.findElement(By.xpath("html/body/div[13]/ul/li[4]/a")); | |
action.moveToElement(we).moveToElement(webdriver.findElement(By.xpath("/expression-here"))).click().build().perform(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define TRACE_ON | |
using System; | |
using System.Diagnostics; | |
namespace AttributeExamples | |
{ | |
public class Trace | |
{ | |
[Conditional("TRACE_ON")] | |
public static void Msg(string msg) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if (e is not null) | |
{ | |
// ... | |
} | |
if (input is null) | |
{ | |
return; | |
} |
NewerOlder