Advertisement
AlexandrP

asdasd

May 12th, 2024
531
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.16 KB | None | 0 0
  1. package org.example;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.chrome.ChromeDriver;
  7.  
  8. public class Main {
  9.     public static void main(String[] args) {
  10.  
  11.         WebDriver driver = new ChromeDriver();
  12.  
  13.         driver.get("https://pastebin.com/");
  14.  
  15.         WebElement pasteCodeField = driver.findElement(By.id("postform-text"));
  16.         pasteCodeField.sendKeys("Hello from WebDriver");
  17.  
  18.         WebElement expirationDropdown = driver.findElement(By.id("select2-postform-expiration-container"));
  19.         expirationDropdown.click();
  20.         WebElement tenMinutesOption = driver.findElement(By.xpath("//li[text()='10 Minutes']"));
  21.         tenMinutesOption.click();
  22.  
  23.         WebElement pasteNameField = driver.findElement(By.id("postform-name"));
  24.         pasteNameField.sendKeys("helloweb");
  25.  
  26.         WebElement createButton = driver.findElement(By.xpath("//button[@class='btn -big']"));
  27.         createButton.click();
  28.  
  29.         String pasteUrl = driver.getCurrentUrl();
  30.         System.out.println("URL of the created paste: " + pasteUrl);
  31.  
  32.         driver.quit();
  33.     }
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement