Skip to main content

Java basic for Selenium - Selenium Tutorial II


Today we are talking about Array. The software tester should have some basic knowledge about java when writing selenium scripts for the validations.
Array is a data structure where stored in elements in same data type. The declaration and initialization an array as follows.

int[]  Array_a;   or  int  Array_a[]; - This is an integer array.
int[10] = Array_num;  - This is an integer array which stores 10 elements.
Array_num[0] = 10;    - Assign value 10 to 0th element of array. (Index [0])
int[]  Array_num = { 1, 2, 3, 4, 5 }; 

Finding maximum value of an array


Finding minimum value of an array


Finding average value of an array


Find the key of an array


Reverse an array
The time complexity of this algorithm is O(n/2) which is O(N) because we are iterating over array till midpoint only.


The initial iteration is happening as follows

The second and the third iterations are happening after that.
The loop is iterating until the middle index. After reversing first, second and third indexes, no need to iterate 4th and 5th indexes because the reverse has been already completed.Please send your comment  and suggestions..  
See you soon with another selenium tutorial........ 
Thanks,
Dananji Withana

Comments


  1. Amazing, thanks a lot my friend, I was also siting like a your banner image when I was thrown into Selenium.When I started learning then I understood it has got really cool stuff.
    I can vouch webdriver has proved the best feature in Selenium framework.
    Thanks a lot for taking a time to share a wonderful article.
    Free PDF: http://www.credosystemz.com/training-in-chennai/best-selenium-training-in-chennai/
    Free Tutorials: http://www.bestseleniumtraininginchennai.in/

    ReplyDelete

Post a Comment

Popular posts from this blog

Strategies and methods for test case design II

Strategies and methods for test case design Today we are talking about how to get an approach for writing a good test case. Developers cannot prevent or eliminate all the defects raised in the application during implementation. That's why the application should be tested before deliver to the customer. Before starting the execution, we need to identify test scenarios and write test cases for each identified scenarios. Test case is test description which needs to be executed to verify the functionality or feature of the application. A good test case have a good possibility of finding defects. For designing effective test cases, there are two basic strategies that can be used. Black box test strategies White box test strategies Test Strategies Sources Testing Techniques Black Box  Functional requirement specification Equivalence partitioning   Business requirement specification Boundary value analysis   Domain knowledge State Transition Testing     ...

Selenium Tutorial I

Create your first script in webdriver Today we are going to learn how to create the selenium script in webdriver.   First, create a new java class according to the below steps.  1. Create a new java project.  2. Enter the following details in the "New Java Project" pop up window. * Project name - Google * Location to save the project - Click on checkbox to use default location * JRE - Select " Use an execution environment JRE " * Project Layout - Click on "Create separate folders for sources and class files" then click on Finish button. 3. Right click on Google project and add new package for the selected project. 4. Enter the valid name for the name of the packa...