Selenium Code Snippets

Selenium Code Snippets


    Running JavaScript via the driver


 Although if we create a function out of it, it does not run.


JavascriptExecutor jsRunner = (JavascriptExecutor) driver;


// This will get us the name of the browser on which the test is running

String jsString = "return navigator.appCodeName";

System.out.println ("BrowserName = " + jsRunner.executeScript(jsString));



    Code to get the text of all the links on a web page


List<WebElement> allLinks = driver.findElements(By.tagName("a"));

for (WebElement link : allLinks){

     System.out.println("Link text = " + link.getText());

}



go to link download

Popular posts from this blog

DroidJack RAT Androrat Android Sample

Modern Combat 2 Black Pegasus apk data Free Download

Notepad 6 6 8