Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.97 KB | None | 0 0
  1. import org.junit.Test;
  2. import org.openqa.selenium.By;
  3. import org.openqa.selenium.WebDriver;
  4. import org.openqa.selenium.firefox.FirefoxDriver;
  5. import org.openqa.selenium.support.ui.ExpectedConditions;
  6. import org.openqa.selenium.support.ui.WebDriverWait;
  7.  
  8. import testlink.api.java.client.TestLinkAPIClient;
  9. import testlink.api.java.client.TestLinkAPIException;
  10. import testlink.api.java.client.TestLinkAPIResults;
  11.  
  12. public class AutomatedUpdateExample {
  13.  
  14. public static String DEVKEY="2f404203b306bd8dd811a7f824c194d0";
  15. public static String URL="http://localhost/testlink/lib/api/xmlrpc/v1/xmlrpc.php";
  16.  
  17. public static void reportResult(String TestProject,String TestPlan,String Testcase,String Build,String Notes,String Result) throws TestLinkAPIException{
  18. TestLinkAPIClient api=new TestLinkAPIClient(DEVKEY, URL);
  19. api.reportTestCaseResult(TestProject, TestPlan, Testcase, Build, Notes, Result);
  20. }
  21.  
  22. @Test
  23. public void Test1()throws Exception
  24. {
  25. AutomatedUpdateExample a=new AutomatedUpdateExample();
  26. WebDriver driver=new FirefoxDriver();
  27. WebDriverWait wait=new WebDriverWait(driver, 600);
  28. String testProject="Gmail";
  29. String testPlan="SampleTestPlan";
  30. String testCase="GmailLogin1";
  31. String build="SampleBuild";
  32. String notes=null;
  33. String result=null;
  34. try{
  35. driver.manage().window().maximize();
  36. driver.get("https://accounts.google.com/ServiceLogin?service=mail&passive=true&rm=false&continue=https://mail.google.com/mail/&ss=1&scc=1&ltmpl=default&ltmplcache=2&emr=1");
  37. driver.findElement(By.id("Email")).sendKeys("testlink.msoftgp");
  38. driver.findElement(By.id("Passwd")).sendKeys("*******");
  39. driver.findElement(By.id("signIn")).click();
  40. driver.switchTo().defaultContent();
  41. wait.until(ExpectedConditions.visibilityOfElementLocated(By.linkText("+Testlink")));
  42. result= TestLinkAPIResults.TEST_PASSED;
  43. notes="Executed successfully";
  44. }
  45.  
  46. catch(Exception e){
  47. result=TestLinkAPIResults.TEST_FAILED;
  48. notes="Execution failed";
  49. }
  50. finally{
  51.  
  52. a.reportResult(testProject, testPlan, testCase, build, notes, result);
  53. driver.quit();
  54. }
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement