Posted By

nathanbain on 01/31/10


Tagged

selenium fitnesse webdriver


Versions (?)

Keyword Driven Testing with FitNesse and WebDriver


 / Published in: Java
 

URL: http://www.meetup.com/agiletesting

Download libs here - http://selenium.googlecode.com/files/webdriver-all-7376.zip

  1. package uk.co.nathanbain.WebTestingFixtures;
  2.  
  3. import org.openqa.selenium.By;
  4. import org.openqa.selenium.WebDriver;
  5. import org.openqa.selenium.WebElement;
  6. import org.openqa.selenium.ie.InternetExplorerDriver;
  7. import fitlibrary.*;
  8.  
  9. public class WebTestingFixtures extends DoFixture
  10.  
  11. {
  12. public static WebDriver driver;
  13.  
  14. public void openBrowser()
  15. {
  16. driver = new InternetExplorerDriver();
  17. }
  18.  
  19. public void closeBrowser()
  20. {
  21. driver.close();
  22. }
  23.  
  24. public void goTo(String url)
  25. {
  26. driver.get(url);
  27. }
  28.  
  29. public void typeIntoTheTextboxWithNameAndSubmit(String text, String txtName)
  30. {
  31. WebElement element = driver.findElement(By.name(txtName));
  32. element.sendKeys(text);
  33. element.submit();
  34. }
  35.  
  36. public boolean confirmThePageContainsTheWords(String text)
  37. {
  38. if(driver.getPageSource().contains(text))
  39. {
  40. return true;
  41. }
  42. return false;
  43. }
  44. }
  45.  
  46. ---------------------------
  47.  
  48. !path lib\fitlibrary.jar
  49. !path fitnesse.jar
  50. !path lib\WebDriver\*.jar
  51.  
  52.  
  53. !define TEST_SYSTEM {fit}
  54. !path C:\fitnesse\bin
  55.  
  56. !|uk.co.nathanbain.WebTestingFixtures.WebTestingFixtures|
  57.  
  58. |open browser|
  59.  
  60. |go to|http://www.google.com|
  61.  
  62. |type|cheese|into the textbox with name|q|and submit|
  63.  
  64. |confirm the page contains the words|www.cheese.com|
  65.  
  66. |close browser|

Report this snippet  

You need to login to post a comment.