User Test Cases: Unauthorized users should not be able to log on to Selenium Master ePortfolio

Unauthorized users should not be able to log on to Selenium Master ePortfolio



User story (Scenario):
Unauthorized users should not be able to log on to Selenium Master ePortfolio

Test Case

Step
Action
Expected Result
Test Data
Actual Result
Test Result
Note
1
Navigate to Selenium Master Test App URL: http://www.seleniummaster.com/seleniummastertestapp/index.php
Log in page displays
    
 2 Enter username in the Username field. Username should be entered and displayed in the username field test   
 3 Enter wrong user password in the Password field. Password should be entered in the password field ?????   
 4 Click on the Log in button. Button should be clicked.    
 5 Verify that "Please check your username and password are correct" message is displayed.     

User Test Cases :Users should be able to change password



Users should be able to change password


User story (Scenario):
User should be able to change password.
Test Case
Step
Action
Expected Result
Test Data
Actual Result
Test Result
Note
1
Navigate to Selenium Master Test App URL: http://www.facebook.com
Log in page displays
 2 Click on the "Lost Username and Password" link Username or password reset page should be displayed.
 3Enter email address or username in the text box fieldEmail address or username should be entered.
 4 Click on the Send Request button Button should be clicked.
 5 Verify that password reset email notification message displayed. 

User Test Cases:User should be able to change user settings

User should be able to change user settings

User story (Scenario):
Users should be able to change user settings.

Test Case

  • Verify that users should be able to log on to the site. (see the corresponding log on test case)
  • Verify that users should be able to change these account settings below:

  • Password
  • Username
  • General account options
  • Notifications
  • Institution Membership
Step
Action
Expected Result
Test Data
Actual Result
Test Result
Note
1
Log on the site with valid username and password
Users should be able to log in the site.
    
 2 Click on the "Settings" link on top of the page My Account page should be displayed.    
 3Check on the radio button "Nobody may add me as a friend"Radio button "Nobody may me as a friend" should be checked.    
 4 Click on the "Save" button Preference saved message should be displayed.    
  • Repeat the above steps for all options under General account options and verify that each change should be saved.
  • Verify each options under Notification with the steps below.
Step
Action
Expected Result
Test Data
Actual Result
Test Result
Note
1
Log on the site with valid username and password
Users should be able to log in the site.
    
 2Click on the "Settings" link on top of the page My Account page should be displayed.    
 3Click on the Notification buttonNotification settings change should be displayed.    
 4Select "inbox" in the System message dropdown list box "Inbox" option should be selected.   
5Click on the "Save" buttonPreference saved message should be displayed.   
  • Repeat the above steps for all options under Notification options and verify that each change should be saved.

Test Scenarios as a user


Test Scenarios as a user


As a user, in addition to log in to the site, change password and change user setting, a user should be able to perform following actions. Each action is a test scenario with various test steps (test steps are omitted here).


  • User should be able to change profile.
  • User should be able to change contact information.
  • User should be able to change messaging.
  • User should be able to change general information.
  • User should be able to change user profile icon.
  • User should be able to add resume.
  • User should be able to upload files.
  • User should be able to upload profile file.
  • User should be able to create dashboard view.
  • User should be able to create profile view.
  • User should be able to copy a view.
  • User should be able to find friends.
  • User should be able to create groups.
  • User should be able to join groups.
  • User should be able to publish a blog.

Test Scenarios as an Admin

Test Scenarios as an Admin

As an admin, in addition to log in to the site, change password and change admin user setting, an admin user should be able to perform following actions. Each action is a test scenario with various test steps (This is not a complete list. test steps are omitted here).

Add caption
  • Admin should be able to change profile.
  • Admin should be able to change contact information.
  • Admin should be able to change messaging.
  • Admin should be able to change general information.
  • Admin should be able to change user profile icon.
  • Admin should be able to add resume.
  • Admin should be able to upload files.
  • Admin should be able to upload profile file.
  • Admin should be able to create dashboard view.
  • Admin should be able to create profile view.
  • Admin should be able to copy a view.
  • Admin should be able to create groups.
  • Admin should be able to publish a blog.
  • Admin should be able to change site settings.
  • Admin should be able to configure site.
  • Admin should be able to manage users.
  • Admin should be able to manage groups.
  • Admin should be able to manage institutions.
  • Admin should be able to manage site extensions.

Basic Action Commands And Operations

1. Creating New Instance Of Firefox Driver
WebDriver driver = new FirefoxDriver();
Above given syntax will create new instance of Firefox driver.


2. Command To Open URL In Browser
driver.get("http://only-testing-blog.blogspot.com/2013/11/new-test.html");
This syntax will open specified URL of software web application in web browser. 

3. Clicking on any element or button of webpage
driver.findElement(By.id("submitButton")).click();
Above given syntax will click on targeted element in webdriver.


4. Store text of targeted element in variable
String dropdown = driver.findElement(By.tagName("select")).getText();
This syntax will retrieve text from targeted element of software web application page and will store it in variable = dropdown.

5. Typing text in text box or text area.
driver.findElement(By.name("fname")).sendKeys("My First Name");
Above syntax will type specified text in targeted element. 

6. Applying Implicit wait in webdriver
driver.manage().timeouts().implicitlyWait(15, TimeUnit.SECONDS);
This syntax will force webdriver to wait for 15 second if element not found on page of software web application. 

7. Applying Explicit wait in webdriver with WebDriver canned conditions.
WebDriverWait wait = new WebDriverWait(driver, 15);
wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//div[@id='timeLeft']"), "Time left: 7 seconds"));
Above 2 syntax will wait for till 15 seconds for expected text "Time left: 7 seconds" to be appear on targeted element.

8. Get page title in selenium webdriver
driver.getTitle();
It will retrieve page title and you can store it in variable to use in next steps.

9. Get Current Page URL In Selenium WebDriver
driver.getCurrentUrl();
It will retrieve current page URL and you can use it to compare with your expected URL.

10. Get domain name using java script executor
JavascriptExecutor javascript = (JavascriptExecutor) driver;
String CurrentURLUsingJS=(String)javascript.executeScript("return document.domain");
Above syntax will retrieve your software application's domain name using webdriver's java script executor interface and store it in to variable.

11. Generate alert using webdriver's java script executor interface
JavascriptExecutor javascript = (JavascriptExecutor) driver;
javascript.executeScript("alert('Test Case Execution Is started Now..');");
It will generate alert during your selenium webdriver test case execution.

12. Selecting or Deselecting value from drop down in selenium webdriver.
  • Select By Visible Text
Select mydrpdwn = new Select(driver.findElement(By.id("Carlist")));
mydrpdwn.selectByVisibleText("Audi");
It will select value from drop down list using visible text value = "Audi".
  • Select By Value
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByValue("Italy");
It will select value by value = "Italy".
  • Select By Index
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.selectByIndex(0);
It will select value by index= 0(First option).



  • Deselect by Visible Text
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByVisibleText("Russia");
It will deselect option by visible text = Russia from list box.
  • Deselect by Value
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByValue("Mexico");
It will deselect option by value = Mexico from list box.
  • Deselect by Index
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectByIndex(5);
It will deselect option by Index = 5 from list box.
  • Deselect All
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
listbox.deselectAll();
It will remove all selections from list box of software application's page.


  • isMultiple()
Select listbox = new Select(driver.findElement(By.xpath("//select[@name='FromLB']")));
boolean value = listbox.isMultiple();
It will return true if select box is multiselect else it will return false.


13. Navigate to URL or Back or Forward in Selenium Webdriver
driver.navigate().to("http://only-testing-blog.blogspot.com/2014/01/textbox.html");
driver.navigate().back();
driver.navigate().forward();
1st command will navigate to specific URL, 2nd will navigate one step back and 3rd command will navigate one step forward. 

14. Verify Element Present in Selenium WebDriver
Boolean iselementpresent = driver.findElements(By.xpath("//input[@id='text2']")).size()!= 0;
It will return true if element is present on page, else it will return false in variable iselementpresent.

15. Capturing entire page screenshot in Selenium WebDriver
File screenshot = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(screenshot, new File("D:\\screenshot.jpg"));
It will capture page screenshot and store it in your D: drive. 
16. Generating Mouse Hover Event In WebDriver
Actions actions = new Actions(driver);
WebElement moveonmenu = driver.findElement(By.xpath("//div[@id='menu1']/div"));
actions.moveToElement(moveonmenu);
actions.perform();
Above example will move mouse on targeted element.


17. Handling Multiple Windows In Selenium WebDriver.
  1. Get All Window Handles.
  2. Set<String> AllWindowHandles = driver.getWindowHandles();
  3. Extract parent and child window handle from all window handles.
  4. String window1 = (String) AllWindowHandles.toArray()[0];
    String window2 = (String) AllWindowHandles.toArray()[1];
  5. Use window handle to switch from one window to other window.
  6. driver.switchTo().window(window2);
Above given steps with helps you to get window handle and then how to switch from one window to another window.

18. Check Whether Element is Enabled Or Disabled In Selenium Web driver.
boolean fname = driver.findElement(By.xpath("//input[@name='fname']")).isEnabled();
System.out.print(fname);
Above syntax will verify that element (text box) fname is enabled or not. You can use it for any input element.
19. Enable/Disable Textbox During Selenium Webdriver Test Case Execution.
JavascriptExecutor javascript = (JavascriptExecutor) driver;
String todisable = "document.getElementsByName('fname')[0].setAttribute('disabled', '');";
javascript.executeScript(todisable);
String toenable = "document.getElementsByName('lname')[0].removeAttribute('disabled');";
javascript.executeScript(toenable);
It will disable fname element using setAttribute() method and enable lname element using removeAttribute() method. 

20. Selenium WebDriver Assertions With TestNG Framework
  • assertEquals
Assert.assertEquals(actual, expected);
assertEquals assertion helps you to assert actual and expected equal values. 
  • assertNotEquals
Assert.assertNotEquals(actual, expected);
assertNotEquals assertion is useful to assert not equal values. 
  • assertTrue
Assert.assertTrue(condition);
assertTrue assertion works for boolean value true assertion. 
Assert.assertFalse(condition);
assertFalse assertion works for boolean value false assertion. 

21. Submit() method to submit form
driver.findElement(By.xpath("//input[@name='Company']")).submit();
It will submit the form.

22. Handling Alert, Confirmation and Prompts Popups

String myalert = driver.switchTo().alert().getText();
To store alert text. 
driver.switchTo().alert().accept();
To accept alert. 

driver.switchTo().alert().dismiss();
To dismiss confirmation. 
driver.switchTo().alert().sendKeys("This Is John");
To type text In text box of prompt popup. - See more at: http://software-testing-tutorials-automation.blogspot.in/2014/01/selenium-webdriver-tutorials-basic.html#sthash.WJjWUsrZ.dpuf

Download And Install MySQL For Database Testing Using Selenium WebDriver

Download And Install MySQL For Database Testing Using Selenium WebDriver
Each and every application has database and It Is very Important to verify that new Inserted or updated record In database Is proper or not. In manual testing, We are executing queries manually to verify, update or delete records but If you are using selenium WebDriver as automation tool then
there should be some way to do same thing using script. My goal Is to show you that how to perform database testing using selenium WebDriver.

Download MySQL Installer
We will learn how to perform database testing using selenium WebDriver with MySQL database. First of all, We need to download MySQL Installer and then we will Install It. Steps to download MySQL are as bellow.

  • On "Download MySQL Installer" page, Click on Download button of "Windows (x86, 32-bit), MSI Installer" as shown bellow. It will ask you to login or register.


  • On login or register page, You can login using your existing oracle account or you need to create new account. After Login, It will take you to Begin Your Download page as bellow.

  • It will show you popup to save mysql Installer file as bellow.

  • Click on Save File button. It will start downloading file and get file like bellow.


Install MySQL Server Using MySQL Installer
Now we have MySQL Installer file using which we can Install MySQL server. Perform bellow given steps to Install MySQL server.
  • Double click on MySQL Installer msi file. It will check your system configuration as bellow.

  • After checking your system configuration, It will open MySQL Installer screen as bellow. Select Custom and click on Next button.

  • On Next screen, Add MySQL server In Features to be Installed box and click on Next button as shown bellow.



  • It will show you ready to Install MySQL on next screen as bellow. Click on Execute button.

  • It will start Installing MySQL server as bellow.

  • When Installation completed, Status will display Ready To Configure. Click on Next button as bellow.

  • On next screen, add port number = 3306 and click on Next button.

  • On next screen, Set password and repeat password and click on Next button. 
Note : Please remember your password. It will be required during Login In MySql. We will use It In test scripts.


  • On Next screen, keep all settings as It Is as shown In bellow Image and click on Next button.

  • Next screen will show you apply server configuration steps. Click on Execute button. It will apply all server settings one by one.



  • When server configuration applied, click on Finish button as bellow.

  • Click on Next button on product configuration step.

  • Click on Finish button on Next screen to finish MySQL server Installation process.

  • When Installation completed, You will see MySQL Command Line Client option In Start menu of Windows as bellow.

Now MySQL Is Installed In your system. We will see how to create new table and execute query In MySQL database manually In Next step.

- See more at: http://software-testing-tutorials-automation.blogspot.in/2015/05/download-and-install-mysql-for-database.html#sthash.0DnE0QRL.dpuf

Handling Dynamic Elements in Selenium WebDriver

                       Handling Dynamic Elements in Selenium WebDriver Dynamic elements are those elements which have identifiers that a...