Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.race_selenium;
- import org.junit.jupiter.api.Test;
- import static org.junit.jupiter.api.Assertions.assertTrue;
- import org.openqa.selenium.By;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.chrome.ChromeDriver;
- public class MileEKm {
- @Test
- public void Test_Mile_E_Km(){
- String []token;
- Double mile;
- // ottengo quanto vale in miglia un kilometro
- System.setProperty("webdriver.chrome.driver", ".\\driver_selenium\\chromedriver.exe");
- WebDriver driver = new ChromeDriver();
- driver.manage().window().maximize();
- driver.get("https://www.unitconverters.net/length/km-to-miles.htm");
- driver.findElement(By.xpath("//*[@id=\"ucfrom\"]")).sendKeys("1");
- token = driver.findElement(By.xpath("//*[@id=\"ucresult\"]")).getText().split("=");
- mile = Double.parseDouble(token[1].split(" ")[1]);
- driver.close();
- // --------------------------------------------
- Double dimpath = mile*20; // quando sono 20 klm in miglia
- int newSpeed = 75; int oldSpeed = 55;
- // Time = ore
- double newTime = dimpath/newSpeed;
- double oldTime = dimpath/oldSpeed;
- double savedTime = oldTime-newTime; // tempo risparmiato in ore
- double savedTimesec = savedTime*3600; // converto ore in secondi
- double upperboundSec = 10*60;
- double lowerboundSec = 10;
- assertTrue(savedTimesec<=upperboundSec && savedTimesec>=lowerboundSec);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement