Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package test;
- import static org.junit.Assert.fail;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.io.OutputStreamWriter;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.concurrent.TimeUnit;
- import org.junit.After;
- import org.junit.Before;
- import org.junit.Test;
- import org.openqa.selenium.By;
- import org.openqa.selenium.NoSuchElementException;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.ie.InternetExplorerDriver;
- public class Roomldl2IE {
- static String[][] post_vars;
- private static int post_var_count;
- private static WebDriver driver;
- private static String baseUrl="http://www.ldlcasino.com";
- private static StringBuffer verificationErrors = new StringBuffer();
- public static void main(String[] args) throws IOException, InterruptedException {
- post_vars = new String[255][255];
- driver = new InternetExplorerDriver();
- driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
- // ERROR: Caught exception [ERROR: Unsupported command [setSpeed]]
- addMessage("Site","LDL Production");
- addMessage("URL",baseUrl);
- driver.get(baseUrl);
- Thread.sleep(30000);
- //System.out.println(isElementPresent(By.id("close_welcome_box")));
- if (isElementPresent(By.id("close_welcome_box")))driver.findElement(By.id("close_welcome_box")).click();
- driver.findElement(By.id("dashTabOverlay")).click();
- Thread.sleep(30000);
- if (isElementPresent(By.id("obRoom"))){driver.findElement(By.id("obRoom")).click();}
- Thread.sleep(30000);
- if (isElementPresent(By.xpath("//form[@id='roomsStep1']/div[7]"))){driver.findElement(By.xpath("//form[@id='roomsStep1']/div[7]")).click();}
- // ERROR: Caught exception [ERROR: Unsupported command [isTextPresent]] By.VisibleText might be wrong
- if (isElementPresent(By.cssSelector("span.dashboardprice"))){addMessage("ldlroomIE","success");}else{addMessage("ldlroomIE ", "FAIL");}
- driver.quit();
- http_post();
- String verificationErrorString = verificationErrors.toString();
- if (!"".equals(verificationErrorString)) {
- fail(verificationErrorString);
- }
- }
- private static boolean isElementPresent(By by) {
- try {
- driver.findElement(by);
- return true;
- } catch (NoSuchElementException e) {
- return false;
- }
- }
- public static void http_post() throws IOException{
- // Construct data
- String data = "";
- for(int n=0; n <=post_vars.length-1; n++){
- if( post_vars[n][0] != null){
- data += post_vars[n][0] + "=" + post_vars[n][1] + "&";
- }
- }
- // Send data
- URL url = new URL("http://logs.skg-i.com/UnitTest.php");
- URLConnection conn = url.openConnection();
- conn.setDoOutput(true);
- OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
- wr.write(data);
- wr.flush();
- // Get the response
- BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
- String line;
- while ((line = rd.readLine()) != null) {
- System.out.println(line);
- }
- wr.close();
- rd.close();
- }
- public static void addMessage(String key, String value){
- post_vars[post_var_count][0] = key;
- post_vars[post_var_count][1] = value;
- post_var_count++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement