Showing posts with label Selenium Basics. Show all posts
Showing posts with label Selenium Basics. Show all posts

October 30, 2015

Run selenium tests in Chrome and IE browser

October 30, 2015 27
How to run the selenium test scripts in Chrome/IE browser ?

To run the selenium test cases in Chrome/IE browser is necessary and need of today's web world as Chrome being the one of the best and most widely used web browser.

Selenium by default supports only Mozilla Firefox . 

To run your tests in Chrome browser please do the following set-up.

1. Download chrome browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.chrome.driver", "Path to chrome related jar file downloaded in step 1");
WebDriver driver = new ChromeDriver();

To run the test in Internet explorer.

1. Download IE browser related jar file from here.

2. Set the System configuration by adding the following code.

System.setProperty("webdriver.ie.driver", "C:\\Users\\ajain5\\Downloads\\IEDriverServer.exe");
WebDriver driver = new InternetExplorerDriver();



October 2, 2015

Handling webtables

October 02, 2015 58
Handling webtables
This post explains about Handling Webtables.

Get Number of Columns
Get Number of Rows
Get Content of a specific cell based on Row and Column value.

Below is the code:



August 3, 2015

Check all check boxes and verify status of check box

August 03, 2015 1
One more example from dave haeffner's weekly tip...

The Problem

Checkboxes, an often used element in web applications. But how do you work with them in your Selenium tests? Intuitively you may reach for a method that has the word 'checked' in it -- like .checked? or .isChecked. But this doesn't exist in Selenium. So how do you do it?

A Solution

There are two ways to approach this -- through an element's 'checked' attribute (a.k.a. an attribute lookup), or by asking the element if it is selected.
boolean org.openqa.selenium.WebElement.isSelected()

  • isSelected

    boolean isSelected()
    Determine whether or not this element is selected or not. This operation only applies to input elements such as checkboxes, options in a select and radio buttons.
    Returns:
    True if the element is currently selected or checked, false otherwise.
Below example shows you how to check all check boxes and verify the status of check boxes.




package sample;

import java.util.List;
import java.util.concurrent.TimeUnit;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

public class Checkboxes_Test {
 public WebDriver driver;

 @Test
 public void testCheckboxes_Test() throws Exception {

  driver.get("http://the-internet.herokuapp.com");
  driver.findElement(By.linkText("Checkboxes")).click();
  //get all the check boxes in web page
  List<WebElement> cBox=driver.findElements(By.cssSelector("input[type='checkbox']"));
  for (int i = 0; i < cBox.size(); i++) {
   //verify check box status, if it is not checked then perform click operation
   if (!cBox.get(i).isSelected()) {
    cBox.get(i).click();
    System.out.println("Check box "+ i + " status is :"+cBox.get(i).isSelected());
   }
   else
   {
    System.out.println("Check box "+ i + " is already selected and status is :"+cBox.get(i).isSelected());
   }
  }
 }

 @BeforeClass
 public void beforeClass() {
  driver = new FirefoxDriver();
  driver.manage().window().maximize();
  driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
 }

 @AfterClass
 public void afterClass() throws Exception {
  driver.quit();
 }

}

December 22, 2010

How to declare IE,FF and Chrome in Selenium

December 22, 2010 0
How to declare IE,FF and Chrome in Selenium
Selenium supported browsers include:



  *firefox
  *mock
  *firefoxproxy
  *pifirefox
  *chrome
  *iexploreproxy
  *iexplore
  *firefox3
  *safariproxy
  *googlechrome
  *konqueror
  *firefox2
  *safari
  *piiexplore
  *firefoxchrome
  *opera
  *iehta
  *custom
 on session null


December 13, 2010

Selenium IDE PPT

December 13, 2010 1
Selenium IDE PPT
Here is the good PPT about selenium

Please click the below link...



Presentation Transcript

Selenium Tutorial :

Selenium Tutorial


What is Selenium? :

What is Selenium? • Javascript framework that runs in your webbrowser • Works anywhere Javascript is supported • Hooks for many other languages • Java, Ruby, Python • Can simulate a user navigating through pages and then assert for specific marks on the pages • All you need to really know is HTML to start using it right away


Where to get it? :

Where to get it? • You can use Selenium-Core and customize everything • But it is easier to just get a Firefox plug-in “Selenium-IDE” that helps you “record” test cases • You can record how an app is being used and then play back those recordings followed by asserts • Get everything at: www.openqa.org/selenium/


Selenium IDE :

Selenium IDE The list of actions in the actual test case to execute The root of web application you want to test The log of the events that were executed, including any errors or warning that may have occurred


Selenium IDE :

Selenium IDE Execution Commands Record test actions Try the test in the Web based TestRunner Specify commands, including asserts Reference of the currently selected command 


Test Creation Demo :

Test Creation Demo • Create test case to log into the gallery • Create test case to log out of the gallery


Slide 7:

Start Pixory Connect to the Server Go to the Login Screen Hit the Record Button


Slide 8:

Type in Username and Password Hit record again to stop Hit submit IDE should update


Slide 9:

Add assertTextPresent and type the text to search for Hit play to make sure your test is successful


Creating a Test Suite :

Creating a Test Suite A Test Suite in Selenium is just an HTML file that contains a table of links to tests Demo Test Suite
Demo Test Suite
TestLogin
TestLogout


Executing the Test Suite :

Executing the Test Suite • Selenium Core is a collection of Javascript and HTML with iFrames • Due to security concerns Core must be deployed within the same server as the application being hosted • The simplest way to run Pixory is to just run the Java application and let it use its own server • Problems using Core with Pixory • Selenium IDE is a plug-in for Firefox and thus can go around these restrictions


Running the Test Suite :

Running the Test Suite • We basically want to execute the test suite using the Selenium IDE plug-in TestRunner.html chrome://selenium-ide/content/selenium/TestRunner.html? baseURL=&test=file:///&auto=true chrome://selenium-ide/content/selenium/TestRunner.html? baseURL=http://localhost:8081&test=file:///Users/ms333/ projects/classes/running/v_and_v/hw3/selenium/test/ TestSuite.html&auto=true


Test Suite :

Test Suite


Test Suite :

Test Suite Execution Control Test Cases Steps of the test case Application being tested


Test Runner Control :

Test Runner Control


Test Runner Control :

Test Runner Control Pause/Play Execution Step through Execution Control Speed of Execution Summary of the Test View the log of the current execution View the DOM of the current Page being tested Highlight Elements in the Execution Run All Tests Run Selected Test


TestRunner Demo :

TestRunner Demo Execute Tests created inside the Firefox TestRunner.