gilt groupe's selenium 2 conversion challenges

24
Findings and Challenges

Upload: sauce-labs

Post on 09-May-2015

2.222 views

Category:

Technology


3 download

DESCRIPTION

See some of the lessons learned by Gilt Groupe as they converted from Selenium 1 to Selenium 2.

TRANSCRIPT

Page 1: Gilt Groupe's Selenium 2 Conversion Challenges

Findings  and  Challenges  

Page 2: Gilt Groupe's Selenium 2 Conversion Challenges

  Background    Tools    Past    Challenges    “The  Decision”      Benefits    Conversion    Present    Examples  

Page 3: Gilt Groupe's Selenium 2 Conversion Challenges

  Custom  framework  written  in  Java    In  house  test  management  system  

  TestElements  ▪  Projects  ▪  Test  Suites    Test  Cases    Actions    Data  Elements    Object  Store  

  Fully  integrated  with  our  Framework  

Page 4: Gilt Groupe's Selenium 2 Conversion Challenges

  Eclipse  IDE    TestElements    Results  Viewer  

  +  iPad  version    SauceLabs    SeleniumIDE  

  Firebug    Ivy    Git  -­‐  version  control  

Page 5: Gilt Groupe's Selenium 2 Conversion Challenges

  Selenium  1  &  Selenium  Grid    6  lab  machines  ▪  Mac’s  and  PCs  with  different  browser  combinations  

  RC  for  each  desired  browser  on  local  machines    RC  for  each  desired  browser  on  each  remote  machine  running  on  SeleniumGrid  

Page 6: Gilt Groupe's Selenium 2 Conversion Challenges

 Maintenance  of  RC’s    If  1  RC  had  an  issue,  must  kill  all  RC’s,  restart  HUB,  and  restart  each  one  again  

  >  800  test  cases  executed  amongst  6  machines  multiple  times  a  day  ▪  (approx.  2500/day)  

  Parallel  execution  was  challenging    Cross  browser  testing  

Page 7: Gilt Groupe's Selenium 2 Conversion Challenges

  Solved  every  challenge  on  the  list    Selenium  RC’s  in  the  cloud  

  No  maintenance    Video    Replaced  Selenium  with  WebDriverBackedSelenium    Selenium  1  backwards  compatible  

  New  code  would  use  WebDriver  

Page 8: Gilt Groupe's Selenium 2 Conversion Challenges

 WebDriverBackedSelenium  on  Sauce    Each  selenium  1  command  would  spit  back  javascript,  causing  very  slow  test  execution  times  

 WebDriver  commands  were  OK    Did  not  realize  this  right  away    Santiago  the  ‘Sauce  Ninja’  

Page 9: Gilt Groupe's Selenium 2 Conversion Challenges
Page 10: Gilt Groupe's Selenium 2 Conversion Challenges

  Convert  EVERYTHING…    No  more  XPATH!  

  CSS_SELECTOR  ▪  Native  support  on  each  browser  

  ID    LINK_TEXT  

Page 11: Gilt Groupe's Selenium 2 Conversion Challenges

  Improve  execution  speed  on  Sauce      (no  more  JavaScript)  

  Better  emulation  of  user  interactions    Better  API  –  More  object  oriented    Stability    Improve  logic  in  codebase    Don’t  want  to  be  left  behind    New  version  of  Selenium  all  the  time  

  Bug  fixes,  improvements    Feel  they  care  about  the  product  

  Fun  

Page 12: Gilt Groupe's Selenium 2 Conversion Challenges

  Line  by  Line  conversion    remove  any  selenium1  references  

  Not  enough  documentation  existed    Not  everything  appeared  to  be  easily  converted    hover  /  mouseOver    select  from  combo  box    attachFile  

Page 13: Gilt Groupe's Selenium 2 Conversion Challenges

  Different  functionality    Objects  must  be  visible  before  acting  on  them    Type  mechanism  does  not  clear  the  text  field  before  filling  it  out  *  changed  in  2.6  

  Selenium2  is  blocking  ▪  No  more  waitForPageToLoad(….)    

  Use  ExpectedCondition  class  to  wait  for  presence  /  visibility  of  element  

  Different  names    no  more  isElementPresent  /  isVisible    

Page 14: Gilt Groupe's Selenium 2 Conversion Challenges

  Simplify  codebase    Find  Selenium2  conversion  for  everything  and  create  wrapper  in  our  Framework  

  SeleniumBase.java  was  born    Custom  WebDriver  commands    All  scripts  extend  from  this  class    Less  clutter   Maintainability  

Page 15: Gilt Groupe's Selenium 2 Conversion Challenges
Page 16: Gilt Groupe's Selenium 2 Conversion Challenges
Page 17: Gilt Groupe's Selenium 2 Conversion Challenges

public WebDriver getWebDriver() { return webDriver;}public WebElement getWebElement(LocatorType locatorType, String locator) throws Exception { return getWebDriver().findElement(by(locatorType, locator));}public List<WebElement> getWebElements(LocatorType locatorType, String locator) throws Exception { return getWebDriver().findElements(by(locatorType, locator));}public boolean isElementPresent(LocatorType locatorType, String locator) throws Exception { return getWebElements(locatorType,locator).size() > 0;}public boolean isVisible(LocatorType locatorType, String locator) throws Exception { return getWebElement(locatorType,locator).isDisplayed();}public void waitForElementPresent(final LocatorType locatorType, final String locator) throws Exception { getWait().until(new ExpectedCondition<Boolean>() { public Boolean apply(WebDriver d) { try { return isElementPresent(locatorType, locator); } catch (Exception e) { return false; } } });}  

Page 18: Gilt Groupe's Selenium 2 Conversion Challenges

public void clearAndSendKeys(LocatorType locatorType, String locator, String keys) throws Exception { getWebElement(locatorType, locator).clear(); getWebElement(locatorType, locator).sendKeys(keys);}public void check(LocatorType locatorType, String locator) throws Exception { if(!getWebElement(locatorType, locator).isSelected()) getWebElement(locatorType, locator).click();}public void mouseOver(LocatorType locatorType, String locator) throws Exception{ Actions action = new Actions(getWebDriver()); action.moveToElement(getWebElement(locatorType, locator)).perform();}public void selectComboBoxByVisibleText(LocatorType locatorType, String locator, String value) throws

Exception{ Select comboBox = new Select(getWebElement(locatorType, locator)); comboBox.selectByVisibleText(value);}public void switchToWindow(String windowTitle){ Set<String> windowHandles = getWebDriver().getWindowHandles();

Iterator<String> iter = windowHandles.iterator();

while(iter.hasNext()){ String currentWindowHandle = iter.next(); getWebDriver().switchTo().window(currentWindowHandle); if(getWebDriver().getTitle().equals(windowTitle)) break;

}}  

Page 19: Gilt Groupe's Selenium 2 Conversion Challenges

clearAndSendKeys(LocatorType.ID,"Gilt Login Page","Email Address Text Field”,emailAddress);clearAndSendKeys(LocatorType.ID,"Gilt Login Page","Password Text Field”,password);getWebElement(LocatorType.ID,"Gilt Login Page","Sign In Button").click();

Page 20: Gilt Groupe's Selenium 2 Conversion Challenges

waitForElementPresentAndVisible(LocatorType.CSS_SELECTOR,"Gilt Carousel Bar","Selected Tab");mouseOver(LocatorType.CSS_SELECTOR,"Gilt Carousel Bar","Selected Tab");List<WebElement> saleTitle = getWebElements(LocatorType.CSS_SELECTOR,"Gilt Carousel Bar","Selected Tab Sale Links");  

Page 21: Gilt Groupe's Selenium 2 Conversion Challenges

List<WebElement> productLookTitleAll = getWebElements(LocatorType.CSS_SELECTOR,"Gilt Product Listing Page","Product Look Title Links");List<WebElement> productLookTitleAvailable = getWebElements(LocatorType.CSS_SELECTOR,"Gilt Product Listing Page","Available Product Look Title Links");List<WebElement> productLookSoldOut = getWebElements(LocatorType.CSS_SELECTOR,"Gilt Product Listing Page","Sold Out Product Look Title Links");  

Page 22: Gilt Groupe's Selenium 2 Conversion Challenges

  99.9999%  converted  to  Selenium2  ▪  attachFile()  

  Stable  results    Clean,  easy  to  manage  code    SeleniumBase  continues  to  grow    Ivy  to  manage  dependencies  

  Upgrade  to  Selenium  2.x  quickly    Push  changes  to  team  through  Git  

Page 23: Gilt Groupe's Selenium 2 Conversion Challenges

 Make  the  switch    Spread  the  work  out  to  save  time  

  Be  aware  of  the  differences  b/t  Sel1  and  Sel2   More  documentation  

 Modularize  common  selenium  commands    Selenium  Users  google  group  

Page 24: Gilt Groupe's Selenium 2 Conversion Challenges

  Question???    Comments….  

Email:  [email protected]    Invitation:  http://www.gilt.com/invite/josesanchez