Showing posts with label Generate random data. Show all posts
Showing posts with label Generate random data. Show all posts

How to Zoom In and Zoom Out in Website

In case, you want to zoom in and out in any website using Selenium. You can follow below commands:

To Zoom In:

WebElement Sel= driver.findElement(By.tagName("html"));
sel.sendKeys(Keys.chord(Keys.CONTROL, Keys.ADD));

To Zoom Out to normal page, use below command:

html.sel(Keys.chord(Keys.CONTROL, "0"));

This can be useful when you need to pin point something while showing your automation framework to any user. 

Generate Random Data


In your scripts, you always want to generate random data to automate SignUp forms, below is code to generate random password. If you need script to generate data to complete forms like available here, do write an email to me:

--------------

public static void main(String[] args) {

//can put any array below depending on requirement
String array = "abcde1234567890~!@#$%^&*()_+";

//calculates its length
int i = array.length();

 //password with length 10
for (int j =0; j<=10; j++)

//randomly picking up 10 characters
{
 int k = (int)(Math.random()*i);
char pass = array.charAt(k);
 System.out.print(pass);
 }
 }