Advertisement
Guest User

watup

a guest
Apr 3rd, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.11 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.*;
  3. import java.text.*;
  4.  
  5. import org.openqa.selenium.By;
  6. import org.openqa.selenium.WebDriver;
  7. import org.openqa.selenium.WebElement;
  8. import org.openqa.selenium.firefox.FirefoxDriver;
  9. import org.openqa.selenium.support.ui.ExpectedCondition;
  10. import org.openqa.selenium.support.ui.WebDriverWait;
  11.  
  12. public class FinalProject{
  13.     public static void main(String[] args) throws IOException{
  14.         Random random = new Random();
  15.         String[] correctAnswers = new String[10];
  16.         String[] userAnswers = new String[10];
  17.         int score = 0, time_elapsed = 0, questionNum;
  18.         WebDriver driver = new FirefoxDriver();
  19.         Scanner sc = new Scanner(System.in);
  20.         System.out.println("Enter your username: ");
  21.         String userName = sc.next();
  22.         System.out.println("Enter your password: ");
  23.         String password = sc.next();
  24.         BufferedReader in = new BufferedReader(new FileReader(new File("UsersInfo_101.txt")));
  25.         String strline;
  26.         int count = 0; count++;
  27.         while((strline = in.readLine()) != null) {
  28.             WebElement user = driver.findElement(By.id("username"));
  29.             WebElement pass = driver.findElement(By.id("password"));
  30.             for(int i = 0; i <= 3; i++){
  31.                 if(userName.equalsIgnoreCase(user.toString()) && password.equals(pass.toString())){
  32.                     BufferedReader br = new BufferedReader(new FileReader(new File("TestBank.txt")));
  33.                     BufferedReader an = new BufferedReader(new FileReader(new File("Answers.txt")));
  34.                     for(int j = 0; j < 10; j++){
  35.                         questionNum = random.nextInt(125)+1;
  36.                         for(int k = 0; k < (questionNum-1); k++){
  37.                             br.readLine();
  38.                             an.readLine();
  39.                         }
  40.                         System.out.println(br.readLine().toString());
  41.                         correctAnswers[j] = an.readLine().toString();
  42.                         userAnswers[j] = sc.next();
  43.                     }
  44.                 }
  45.             }
  46.         }
  47.     }
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement