Examples/comparison.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59

<#
public void testClass() throws Exception {
    driver.get("http://www.wikipedia.org/") ;
    Assert.assertequals("wikipedia", driver.getTitle());
    Assert.assertequals("English", driver.findElement(By.cssselector("strong")).getText())
    driver.findElement(By.cssSetector("strong")).click() ;
    Assert.assertEquals("Wikipedia. the free encyclopedia", driver.getTitle());
}
#>

SeOpen "http://www.wikipedia.org/"
SeShouldHave -Title eq Wikipedia
SeShouldHave 'strong' -By CssSelector -With  Text eq 'English' -PassThru | SeClick
SeShouldHave -Title eq 'Wikipedia, the free encyclopedia'

<#
line 2 ## SeShouldHave -Title eq Wikipedia
is actutally short for ## SeShouldHave -Title -Operator 'eq' -Value Wikipedia
other values for -operator will translate to "eq", and parameters are defined so you can use -eq -contains, -match etc
so you can use ## SeShouldHave -Title equalTo Wikipedia
or ## SeShouldHave -Title -eq Wikipedia
line 3 ## SeShouldHave 'strong' -By CssSelector Text eq 'English'
This is short for ## SeShouldHave -Selection 'strong' -By CssSelector -With Text -operator "eq" -value 'English'
if the selector is an xPath the -By parameter can be omitted; but if used -By must specified explicitly
The first unnamed parameter will be treated as selection, the second as "with" , the third as operator and the fourth as value.
SeShouldhave can take a -passthru parameter allowing the original lines 3 and 4 to be merged,
 
The last line 5 is similar to line 2 but the parameter value has a sppace so must be wrapped in quotes
#>


<#https://www.guru99.com/first-webdriver-script.html had this
public static void main(String[] args) {
    System.setProperty("webdriver.gecko.driver","C:\\geckodriver.exe");
    WebDriver driver = new FirefoxDriver();
    //comment the above 2 lines and uncomment below 2 lines to use Chrome
    //System.setProperty("webdriver.chrome.driver","G:\\chromedriver.exe");
    //WebDriver driver = new ChromeDriver();
 
    String baseUrl = "http://demo.guru99.com/test/newtours/";
    driver.get(baseUrl);
 
    String expectedTitle = "Welcome: Mercury Tours";
    String actualTitle = "";
    actualTitle = driver.getTitle();
    if (actualTitle.contentEquals(expectedTitle)){
        System.out.println("Test Passed!");
    } else {
        System.out.println("Test Failed");
    }
 
    driver.close();
}
#>


SeOpen "http://demo.guru99.com/test/newtours/" -In FireFox # or #-in Chrome -in MsEdge -in NewEdge or -in IE
SeShouldHave -Title eq "Welcome: Mercury Tours"
SeClose