Saturday, 29 August 2015

4. Forms and other elements (Part 1)

Forms and other elements



4.1. Clicking links and buttons



1. Buttons & Hyperlinks

2. Keys combinations

3. Actions

4. Execute JavaScript





1. Buttons & Hyperlinks


$("#element").click();

$("#element").doubleClick();


$(By.linkText("Logout")).click();

$("#agreement").submit();

$(".g").contextClick();    // context menu


2. Keys combinations


Submit with Enter:

open("http://google.com");

$("#lst-ib").val("qwertyuiop").pressEnter();

$("q").pressEnter();


To navigate (Tab):

$("q").pressTab();


To select all (Ctrl-A):

 open("http://google.com");
 $("#lst-ib").val("qwertyuiop");

 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "a"));

To copy (Ctrl-C):

 open("http://google.com");
 $("#lst-ib").val("qwertyuiop");
 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "a"));

 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "c"));

To cut (Ctrl-X):

 open("http://google.com");
 $("#lst-ib").val("qwertyuiop");
 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "a"));

 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "x"));

To paste (Ctrl-V):

 $("#lst-ib").sendKeys(Keys.chord(Keys.CONTROL, "v"));



3. Actions


actions().click($("#lst-ib").val("selenide")).build().perform();



4. Execute JavaScript


executeJavaScript("console.log('Hello')");




Source: Selenide Cheat Sheet

No comments:

Post a Comment