Trsak

Untitled

Sep 18th, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. import org.openqa.selenium.By;
  2. import org.openqa.selenium.WebDriver;
  3. import org.openqa.selenium.WebElement;
  4. import org.openqa.selenium.chrome.ChromeDriver;
  5.  
  6. import java.util.List;
  7.  
  8.  
  9. public class Gustik {
  10. enum Currencies {
  11. EUR,
  12. AUD,
  13. CAD
  14. }
  15.  
  16. public static void main(String[] args) {
  17. Currencies currency = Currencies.AUD;
  18.  
  19. System.setProperty(
  20. "webdriver.chrome.driver",
  21. "D:\\School\\chromedriver.exe");
  22.  
  23. WebDriver webDriver = new ChromeDriver();
  24. webDriver.navigate().to("https://www.sberbank.cz/");
  25.  
  26. webDriver.findElement(By.xpath("//a[@href='/cs-cz/poplatky-a-sazby/kurzy']")).click();
  27. WebElement table = webDriver.findElement(By.xpath("//table"));
  28. List<WebElement> tableCells = table.findElements(By.xpath("//th"));
  29.  
  30. int index = -9;
  31. for (WebElement tableCell : tableCells) {
  32. ++index;
  33. if (tableCell.getText().equals(currency.name())) {
  34. System.out.println(table.findElement(By.xpath("//tr[" + (index + 1) + "]//td[1]")).getText());
  35. }
  36. }
  37. }
  38. }
  39.  
Add Comment
Please, Sign In to add comment