Advertisement
Guest User

Untitled

a guest
Jan 26th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.30 KB | None | 0 0
  1. package shits;
  2.  
  3. import java.io.File;
  4. import java.io.IOException;
  5. import java.util.List;
  6. import java.util.concurrent.TimeUnit;
  7.  
  8. import javax.swing.JFrame;
  9. import javax.swing.JOptionPane;
  10. import javax.swing.JPasswordField;
  11.  
  12. import org.apache.commons.io.FileUtils;
  13. import org.openqa.selenium.By;
  14. import org.openqa.selenium.Capabilities;
  15. import org.openqa.selenium.OutputType;
  16. import org.openqa.selenium.TakesScreenshot;
  17. import org.openqa.selenium.WebDriver;
  18. import org.openqa.selenium.WebElement;
  19. import org.openqa.selenium.remote.DesiredCapabilities;
  20. import org.openqa.selenium.phantomjs.PhantomJSDriver;
  21. import org.openqa.selenium.phantomjs.PhantomJSDriverService;
  22.  
  23.  
  24. public class readurlbugged {
  25.  
  26.     public static void main(String[] args) throws IOException
  27.     {
  28.         String user = JOptionPane.showInputDialog("User: ");
  29.         JPasswordField pass = new JPasswordField(10);
  30.         int action = JOptionPane.showConfirmDialog(null, pass,"Enter Password",JOptionPane.OK_CANCEL_OPTION);
  31.         if(action < 0)JOptionPane.showMessageDialog(null,"Cancel, X or escape key selected");
  32.  
  33.         String realpass = String.valueOf(pass.getPassword());
  34.        
  35.         String members = JOptionPane.showInputDialog("Numar membri:");
  36.         int membri = Integer.parseInt(members);
  37.        
  38.        
  39.         Capabilities caps = new DesiredCapabilities();
  40.         ((DesiredCapabilities) caps).setJavascriptEnabled(true);                
  41.         ((DesiredCapabilities) caps).setCapability("takesScreenshot", true);  
  42.         ((DesiredCapabilities) caps).setCapability(
  43.                 PhantomJSDriverService.PHANTOMJS_EXECUTABLE_PATH_PROPERTY,
  44.                 "phantomjs-2.1.1-windows/phantomjs-2.1.1-windows/bin/phantomjs.exe"
  45.             );
  46. WebDriver   driver = new  PhantomJSDriver(caps);
  47.        
  48.         driver.get("http://redpanel.bugged.ro/login/");
  49.         System.out.println(driver.getTitle());
  50.         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  51.         System.out.println(driver.getTitle());
  52.         driver.findElement(By.name("username")).clear();
  53.         driver.findElement(By.name("username")).sendKeys(user);
  54.         driver.findElement(By.name("password")).clear();
  55.         driver.findElement(By.name("password")).sendKeys(realpass);
  56.         driver.findElement(By.xpath("/html/body/div[2]/div[2]/div[2]/div/div/center/form/input[3]")).click();
  57.         driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
  58.         System.out.println(driver.getTitle());
  59.         File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
  60.         FileUtils.copyFile(scrFile, new File("C:/Users/Eugen/Desktop/screenshot.png"));
  61.         driver.get("http://redpanel.bugged.ro/clan/view/47");
  62.         System.out.println(driver.getTitle());
  63.         String instring;
  64.         int m = 1;
  65.        
  66.         for (int i = 1; i<=membri; i++)  
  67.         {
  68.         driver.findElement(By.xpath("/html/body/div[2]/div[2]/div[2]/div/div/div[2]/div[2]/div/div[2]/div/ul/li["+m+"]/a")).click();;
  69.         System.out.println(i + ". "  + driver.getTitle());
  70.         String ore = driver.findElement(By.cssSelector("#home > div > div.span10 > div:nth-child(7) > div:nth-child(5) > div.profile-info-value > span")).getText();
  71.         System.out.println("\t"+ore);
  72.         driver.navigate().back();
  73.         m++;
  74.         }
  75.     }
  76.    
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement