Created
December 17, 2017 10:36
-
-
Save mknorth/0c384c3a6c18524ba91bee831941a691 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework3; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebElement; | |
import org.testng.annotations.AfterGroups; | |
import org.testng.annotations.Test; | |
public class BanksExample extends BrowserLogin { | |
double averagePurchase; | |
double averageSele; | |
double aPrb,aUkrSib,strAval12,strOB1; | |
double bPrb,bUkrSib,strAval22,strOB2; | |
double str; | |
double x,x2,y,y2,z,z2; | |
@Test(groups = "tD") | |
public void prBank() { | |
driver.get("https://www.privat24.ua"); | |
WebElement element = driver.findElement(By.xpath("//div[@class='section'][1]/div[2]")); | |
String str = element.getText(); | |
String substr = "/"; | |
String[] parts = str.split(substr); | |
String before = parts[0]; | |
String after = parts[1]; | |
aPrb = Double.parseDouble(before); | |
bPrb = Double.parseDouble(after); | |
} | |
@Test(groups = "tD") | |
public void ukrSib() { | |
driver.get("https://my.ukrsibbank.com/ru/personal/operations/currency_exchange/"); | |
WebElement element1 = driver.findElement(By.xpath("//table[@class='currency__table']//tbody/tr[1]/td[2]")); | |
String strUkrSib1 = element1.getText(); | |
WebElement element2 = driver.findElement(By.xpath("//table[@class='currency__table']//tbody/tr[1]/td[3]")); | |
String strUkrSib2 = element2.getText(); | |
aUkrSib = Double.parseDouble(strUkrSib1); | |
bUkrSib = Double.parseDouble(strUkrSib2); | |
} | |
@Test(groups = "tD") | |
public void bankAval(){ | |
driver.get("https://www.aval.ua/ru/personal/everyday/exchange/exchange/"); | |
WebElement element1 = driver.findElement(By.xpath("//div[@class='body-currency-block-rba']//tbody/tr[2]/td[2]")); | |
WebElement element2 = driver.findElement(By.xpath("//div[@class='body-currency-block-rba']//tbody/tr[2]/td[3]")); | |
String strAval1 = element1.getText(); | |
strAval1 = strAval1.replace(',','.'); | |
String strAval2 = element2.getText(); | |
strAval2 = strAval2.replace(',','.'); | |
strAval12 = Double.parseDouble(strAval1); | |
strAval22 = Double.parseDouble(strAval2); | |
} | |
@Test(groups = "tD") | |
public void oschadBank(){ | |
driver.get("http://www.oschadbank.ua/ua/"); | |
WebElement element1 = driver.findElement(By.xpath("//strong[@class='buy-USD']")); | |
WebElement element2 = driver.findElement(By.xpath("//strong[@class='sell-USD']")); | |
String str1 = element1.getText(); | |
str1 = str1.replace(',','.'); | |
String str2 = element2.getText(); | |
str2 = str2.replace(',','.'); | |
strOB1 = Double.parseDouble(str1); | |
strOB2 = Double.parseDouble(str2); | |
} | |
@Test(groups = "tD") | |
public void nbuExample(){ | |
driver.get("https://bank.gov.ua/control/uk/curmetal/detail/currency?period=daily"); | |
WebElement element = driver.findElement(By.xpath("//div[@class='content']/table[4]//tr[9]/td[5]")); | |
str = Double.parseDouble(element.getText()); | |
str = str/100; | |
} | |
@AfterGroups (groups = "tD") | |
public void BankEX2(){ | |
averagePurchase = (aPrb + aUkrSib + strAval12 + strOB1)/4; | |
averageSele = (bPrb + bUkrSib + strAval22 + strOB2)/4; | |
if (aPrb < aUkrSib){ | |
x = aPrb; | |
}else { | |
x = aUkrSib; | |
} | |
if (strAval12 < strOB1){ | |
y = strAval12; | |
}else { | |
y = strOB1; | |
} | |
if (x < y){ | |
z = x; | |
}else { | |
z = y; | |
} | |
if (bPrb > bUkrSib){ | |
x2 = bPrb; | |
}else { | |
x2 = bUkrSib; | |
} | |
if (strAval22 > strOB2){ | |
y2 = strAval22; | |
}else { | |
y2 = strOB2; | |
} | |
if (x2 > y2){ | |
z2 = x2; | |
}else { | |
z2 = y2; | |
} | |
if (z == aPrb) { | |
System.out.println("Минимальное цена продажи Доллара в ПриватБанке: " + z); | |
} else if (z == aUkrSib){ | |
System.out.println("Минимальное цена продажи Доллара в Укрсибе: " + z); | |
} else if (z == strAval12){ | |
System.out.println("Минимальное цена продажи Доллара в Райфайзен: " + z); | |
} else { | |
System.out.println("Минимальное цена продажи Доллара в ОщадБанке: " + z); | |
} | |
if (z2 == bPrb) { | |
System.out.println("Максимальное цена покупки Доллара в ПриватБанке: " + z2); | |
} else if (z2 == bUkrSib){ | |
System.out.println("Максимальное цена покупки Доллара в Укрсибе: " + z2); | |
} else if (z2 == strAval22){ | |
System.out.println("Максимальное цена покупки Доллара в Райфайзен: " + z2); | |
} else { | |
System.out.println("Максимальное цена покупки Доллара в ОщадБанке: " + z2); | |
} | |
// Double[] doubleArr1 = {aPrb,aUkrSib,strAval12,strOB1}; | |
// double minArr1 = doubleArr1[0]; | |
// for(Double value1 : doubleArr1) { | |
// if (value1 < minArr1) { | |
// minArr1 = value1; | |
// } | |
// } | |
// | |
// Double[] doubleArr2 = {bPrb,bUkrSib,strAval22,strOB2}; | |
// double maxArr2 = doubleArr2[0]; | |
// for(Double value2 : doubleArr2) { | |
// if (value2 > maxArr2) { | |
// maxArr2 = value2; | |
// } | |
// } | |
// if (minArr1 == aPrb) { | |
// System.out.println("Минимальное цена продажи Доллара в ПриватБанке: " + minArr1); | |
// } else if (minArr1 == aUkrSib){ | |
// System.out.println("Минимальное цена продажи Доллара в Укрсибе: " + minArr1); | |
// } else if (minArr1 == strAval12){ | |
// System.out.println("Минимальное цена продажи Доллара в Райфайзен: " + minArr1); | |
// } else { | |
// System.out.println("Минимальное цена продажи Доллара в ОщадБанке: " + minArr1); | |
// } | |
// if (maxArr2 == bPrb) { | |
// System.out.println("Максимальное цена покупки Доллара в ПриватБанке: " + maxArr2); | |
// } else if (maxArr2 == bUkrSib){ | |
// System.out.println("Максимальное цена покупки Доллара в Укрсибе: " + maxArr2); | |
// } else if (maxArr2 == strAval22){ | |
// System.out.println("Максимальное цена покупки Доллара в Райфайзен: " + maxArr2); | |
// } else { | |
// System.out.println("Максимальное цена покупки Доллара в ОщадБанке: " + maxArr2); | |
// } | |
System.out.println("Курс НБУ: " + str); | |
System.out.println("Среднее покупка по банкам: " + averagePurchase); | |
System.out.println("Среднее продажа по банкам: " + averageSele); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework3; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import org.testng.annotations.AfterGroups; | |
import org.testng.annotations.AfterTest; | |
import org.testng.annotations.BeforeTest; | |
public class BrowserLogin { | |
public WebDriver driver; | |
@BeforeTest | |
public void SetUp(){ | |
driver = new ChromeDriver(); | |
} | |
// @AfterGroups(groups = "tD") | |
// public void BankEX2(){ | |
// BanksExample bx = new BanksExample(); | |
// | |
// bx.averagePurchase = (bx.aPrb + bx.aUkrSib + bx.strAval12 + bx.strOB1)/4; | |
// bx.averageSele = (bx.bPrb + bx.bUkrSib + bx.strAval22 + bx.strOB2)/4; | |
// | |
// Double[] doubleArr1 = {bx.aPrb,bx.aUkrSib,bx.strAval12,bx.strOB1}; | |
// double minArr1 = doubleArr1[0]; | |
// for(Double value1 : doubleArr1) { | |
// if (value1 < minArr1) { | |
// minArr1 = value1; | |
// } | |
// } | |
// | |
// Double[] doubleArr2 = {bx.bPrb,bx.bUkrSib,bx.strAval22,bx.strOB2}; | |
// double maxArr2 = doubleArr2[0]; | |
// for(Double value2 : doubleArr2) { | |
// if (value2 > maxArr2) { | |
// maxArr2 = value2; | |
// } | |
// } | |
// | |
// | |
// if (minArr1 == bx.aPrb) { | |
// System.out.println("Минимальное цена продажи Доллара в ПриватБанке: " + minArr1); | |
// } else if (minArr1 == bx.aUkrSib){ | |
// System.out.println("Минимальное цена продажи Доллара в Укрсибе: " + minArr1); | |
// } else if (minArr1 == bx.strAval12){ | |
// System.out.println("Минимальное цена продажи Доллара в Райфайзен: " + minArr1); | |
// } else { | |
// System.out.println("Минимальное цена продажи Доллара в ОщадБанке: " + minArr1); | |
// } | |
// if (maxArr2 == bx.bPrb) { | |
// System.out.println("Максимальное цена покупки Доллара в ПриватБанке: " + maxArr2); | |
// } else if (maxArr2 == bx.bUkrSib){ | |
// System.out.println("Максимальное цена покупки Доллара в Укрсибе: " + maxArr2); | |
// } else if (maxArr2 == bx.strAval22){ | |
// System.out.println("Максимальное цена покупки Доллара в Райфайзен: " + maxArr2); | |
// } else { | |
// System.out.println("Максимальное цена покупки Доллара в ОщадБанке: " + maxArr2); | |
// } | |
// | |
// System.out.println("Среднее покупка по банкам: " + bx.averagePurchase); | |
// System.out.println("Среднее продажа по банкам: " + bx.averageSele); | |
// } | |
@AfterTest | |
public void BankEX(){ | |
// BanksExample gp = new BanksExample(); | |
// | |
// gp.averagePurchase = (gp.aPrb + gp.aUkrSib + gp.strAval12 + gp.strOB1)/4; | |
// gp.averageSele = (gp.bPrb + gp.bUkrSib + gp.strAval22 + gp.strOB2)/4; | |
// | |
// System.out.println("Среднее покупка по банкам: " + gp.averagePurchase); | |
// System.out.println("Среднее покупка по банкам: " + gp.averageSele); | |
driver.quit(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package homework3; | |
import org.openqa.selenium.By; | |
import org.openqa.selenium.WebDriver; | |
import org.openqa.selenium.WebElement; | |
import org.openqa.selenium.chrome.ChromeDriver; | |
import java.util.List; | |
public class LiniaKinoExample { | |
public static void main(String[] args) throws InterruptedException { | |
WebDriver driver = new ChromeDriver(); | |
driver.get("http://liniakino.com/showtimes/aladdin/"); | |
driver.findElement(By.xpath("//*[@id='closeButton']")).click(); | |
driver.findElement(By.xpath("//*[@class='showtime-movie'][1]/div[@class='showtime']/div[1]//li[@class='showtime-item'][1]/a")).click(); | |
Thread.sleep(5000); | |
WebElement starWarsFrame = driver.findElement(By.xpath("//*[@class='arcticmodal-container_i']//iframe")); | |
driver.switchTo().frame(starWarsFrame); | |
List<WebElement> atAllSeats = driver.findElements(By.xpath("//*[@id='hall-scheme-container']/div/child::div")); | |
System.out.println("Всего мест в зале: " + atAllSeats.size()); | |
List<WebElement> freeSeats = driver.findElements(By.xpath("//*[@id='hall-scheme-container']//div[@class='seat seat-color1']")); | |
System.out.println("Свободных мест: " + freeSeats.size()); | |
List<WebElement> occupiedSeats = driver.findElements(By.xpath("//*[@id='hall-scheme-container']//div[@class='seat seat-occupied']")); | |
System.out.println("Занятых мест: " + occupiedSeats.size()); | |
List<WebElement> reservedSeats = driver.findElements(By.xpath("//*[@id='hall-scheme-container']//div[@class='seat seat-reserved']")); | |
System.out.println("Резерв мест: " + reservedSeats.size()); | |
int persentPlases = (((reservedSeats.size() + freeSeats.size())*100)/atAllSeats.size()); | |
System.out.println("Процент свободных мест: " + persentPlases + "%"); | |
System.out.println("Процент занятых мест: " + (100 - persentPlases) + "%"); | |
Thread.sleep(3000); | |
driver.quit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment