简体   繁体   中英

How to write selenium script for taking random alphanumeric number from a list

I need help in selenium script. I need to take random alphanumeric values from my table list. How I can do it in selenium? I want to use

String uniqueID = UUID.randomUUID().toString(); 

This in my selenium script. But I don't know how to use?

As mentioned in my comment, it won't be possible to match the newly generated UUID.randomUUID().toString() with any of the the predefined values within your table list.

However, to generate and send a random number to the Search Box on Google Home Page you can use the following solution:

  • Code Block :

     import java.util.UUID; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; public class RandomNumbers_GoogleSearchBox { public static void main(String[] args) { System.setProperty("webdriver.gecko.driver", "C:\\\\Utility\\\\BrowserDrivers\\\\geckodriver.exe"); WebDriver driver = new FirefoxDriver(); driver.get("https://www.google.com/"); new WebDriverWait(driver, 20).until(ExpectedConditions.elementToBeClickable(By.name("q"))).sendKeys(UUID.randomUUID().toString()); } } 
  • Browser Snapshot:

random_UUID

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM