Advertisement
Guest User

Untitled

a guest
May 28th, 2015
245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.38 KB | None | 0 0
  1. /**
  2.  * Landing Page Test.
  3.  *
  4.  * @author ebartalos
  5.  */
  6. public class GoogleBratislavaSearch
  7.     extends PHXShared_AutomationTest
  8. {
  9.  
  10.     /**
  11.      * Main testing method.
  12.      */
  13.     @Override
  14.     public void execute() {
  15.  
  16.         // Go to https://www.google.com/?gws_rd=ssl
  17.         navigateToCertainPage(" https://www.google.com/?gws_rd=ssl", false);
  18.  
  19.         // Verify presence of logo
  20.         verifyElementPresent(By.id("hplogo"), "logo");
  21.  
  22.         // Verify presence of search input field
  23.         verifyElementPresent(By.id("lst-ib"), "searchInput");
  24.  
  25.         // Verify presence of search button
  26.         verifyElementPresent(By.name("btnK"), "searchSubmit");
  27.  
  28.         // Verify presence of feeling lucky button
  29.         verifyElementPresent(By.name("btnI"), "feelingLucky");
  30.  
  31.         // Verify presence of footer
  32.         verifyElementPresent(By.id("fbar"), "footer");
  33.  
  34.         // Verify presence of left half of footer
  35.         verifyElementPresent(By.id("fsl"), "footerLeft");
  36.  
  37.         // Verify presence of right half of footer
  38.         verifyElementPresent(By.id("fsr"), "footerRight");
  39.  
  40.         // Verify presence of "cookie" bar in footer
  41.         verifyElementPresent(By.id("epbar"), "cookieBar");
  42.  
  43.         // Type "Bratislava" in the search input
  44.         enterTextIntoElement(By.id("lst-ib"), "Bratislava", "Bratislava");
  45.  
  46.         // Click search button
  47.         clickElement(By.name("btnG"), "clickSearch");
  48.  
  49.         // Verify if wikipedia is displayed in search results
  50.         isTextPresent(By.id("gsr"), "wikipedia.org/wiki/Bratislava");
  51.     }
  52. }
  53. 1. You do not have to add comment to each line. Better split your comment into some logical parts and add comments to them, for example
  54. //Verify elements of the page
  55. ...
  56. //Verify elements of the footer
  57. ...
  58. //Perform search and verify the search results are correct
  59.  
  60. 2. It's better to use verifyElementVisible, not verifyElementPresent. verifyElementVisible verifies that the element is actually displayed on the page, while verifyElementPresent just verifies element is in HTML (but can be invisible)
  61.  
  62. 3. "isTextPresent" returns just true or false, and writes information line. It does not fail the test if the text is not there!!!! So you are not catching the bug, if the link is not there. In your case I would use verifyTextPresent or verifyElementIsVisible(By.xpath("//a[contains(.,Bratislava - Wikipedia, the free encyclopedia)]"));
  63. 4. Your comment to the class name is wrong :) /**
  64. * Landing Page Test.
  65. 5. I would check presence of each link in the footer (Advertising, Business, etc)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement