Monday 13 August 2018

Did You Face Pods Stuck On Terminating Issue While Deleting The Namespace In Kubernetes ?

You might have faced a situation of "Pods getting stuck on terminating" issue when trying to delete the namespace. This could be irritating especially when you might need the namespace delete results instantly.









No Problem, Kubernetes has provided a way to deal with this situation. We need to force delete the pod providing the pod name and namespace

Force Delete Command➤

< kubectl delete pod "podname" -n "namespace" --grace-period=0 --force >

Now, What if you have 10 to 20 Pods listed in "terminating status" even when you have issued a delete namespace command. So Now, You may need to force delete all of them one by one. 

But deleting them manually could be a cumbersome job and needs a lot of patience.

Well, there is a way where you can deal with this situation as well:

Code 1➤ Groovy Code to force delete multiple pods

Code 2➤ Shell Script Code to force delete multiple pods



Shell Script Code To Force Delete Multiple Pods From Kubernetes

There might be a situation where you have 10 to 20 Pods listed in "terminating status" even when you have issued a delete namespace command. So Now, You may need to force delete all of them. 

But deleting them manually could be a cumbersome job and needs a lot of patience.

Well, there is a way where you can deal with this situation as well:











Code 2➤ Shell Script Code to force delete multiple pods
Create a folder and save below code to your sample.sh file. Now open the git bash and navigate to the folder where you have kept your sample.sh code.

Now run the below command.

➤ sh sample.sh

namespace="yournamespace"
outputPods=($(kubectl get pods -o=name -n $namespace))
podsCount=${#outputPods[@]}
if [ $podsCount -gt 0 ]
then
for (( i=0; i < ${podsCount}; i++ ));
do
   podName=(${outputPods[i]/pod\//})
   echo $(kubectl delete pod ${podName} -n $namespace --grace-period=0 --force)
done
else
   echo "No Pods listed"
fi


Groovy Code To Force Delete Multiple Pods From Kubernetes

There might be a situation where you have 10 to 20 Pods listed in "terminating status" even when you have issued a delete namespace command. So Now, You may need to force delete all of them. 

But deleting them manually could be a cumbersome job and needs a lot of patience.

Well, there is a way where you can deal with this situation as well:







Code 1➤ Groovy Code to force delete multiple pods
Create a folder and save below code to your sample.groovy file. Now open the command prompt or git bash and navigate to the folder where you have kept your sample.groovy code.

Now run the below command.

➤ groovy sample.groovy

NOTE: you have to install groovy if it is not installed already


nameSpace="yournamespace"
getPods="kubectl get pods -o=name -n "+nameSpace+""pods = getPods.execute().text

if(!pods.allWhitespace && !pods.equals("No resources found.")){

    def podNames = pods.split('\n')
    for (int i=0; i <  podNames.length; i++){
        command  = "kubectl delete pod "+""+podNames[i].replace( 'pod/', '' ).trim()+""+" -n "+nameSpace+" --grace-period=0 --force"        println command.execute().text
    }

}else{
    println "No Pods Listed"}
Code 2➤ Shell Script Code to force delete multiple pods



Saturday 11 August 2018

All You Need To Know About Efficient Network Access And Sending JSON object Using OkHttp

Sometime you may need to POST the events to the endpoint based on your project needs. There are various APIs available to request and get the response from the events in the market but when I came across OkHttp I started loving the simplicity of it.
It is one of the APIs that is very easy to understand and easy to use. OkHttp is mostly used to exchange data & media. Doing HTTP efficiently using it makes your data load faster and saves bandwidth.



Below are some of the features of OkHttp:
  1. Connection pooling reduces request latency
  2. It will silently recover from common connection problems
  3. If your service request has multiple IP addresses OkHttp will attempt alternate addresses if the first connection fails.
  4. OkHttp initiates new connections with modern TLS features (SNI, ALPN), and falls back to TLS 1.0 if the handshake fails.

Now why to wait, let's see how we use the OkHttp in our Code. So as part of this tutorial, I am performing below operations:

  1. Send Login Event
  2. CreateSession Event
  3. Publish Event
Sending Login Event:  You can create your own SampleUtil and add login method to that class. The method below is calling a login() method of SampleUtil. Login method will return the response object which will be stored in the reference variable "response". This variable later can be used to validate the response code which in this case is 200.  You need to fetch the "jwt" from the response which you will need to Create a Session event later.

public void iSendLoginRequest() throws Throwable {
    try {
        Response response = SampleUtil.login("http://loginurl:8080", jsonBody);
        assertEquals(responseCode, response.code());
        String responseBody = response.body().string();
        JSONObject object = new JSONObject(responseBody);
        String jwtToken = object.getString("jwt");
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}
SampleUtil.java Code:
public static Response login(String loginUrl, String jsonBody) {
     try {
         RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonBody);

         OkHttpClient client = new OkHttpClient();
         okhttp3.Request request = new okhttp3.Request.Builder()
                 .url(loginUrl)
                 .post(body)
                 .build();

         return client.newCall(request).execute();
     } catch (Exception e) {
         e.printStackTrace();
     }
     return null;
 }
Performing Create Session Event: createSession() takes the URL, JSON body and JWT as the parameters and method will return the response object which will be stored in the reference variable "response". This variable later can be used to validate the response code which in this case is 200. Along with that, you need to fetch the "sessionId" from the response which you need to Publish the event later.

public void iCreateSessionRequest() throws Throwable {
    try {
        Response response = SampleUtil.createSession("http://createsessionurl:8080",jsonBody, jwtToken);
        assertEquals(responseCode, response.code());
        String responseBody = response.body().string();
        JSONObject object = new JSONObject(responseBody);
        sessionId = object.getString("sessionId");

    } catch (Exception e) {
        e.printStackTrace();
    }
}

SampleUtil.java Code:
 public static Response createSession(String createSessionUrl, String jsonBody, String jwt) {
    try {
        RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonBody);
        OkHttpClient client = new OkHttpClient();
        okhttp3.Request request = new okhttp3.Request.Builder()
                .url(createSessionUrl)
                .addHeader("Authorization", "Bearer " + jwt)
                .post(body)
                .build();

        return client.newCall(request).execute();

    } catch (Exception e) {
         e.printStackTrace();
    }
    return null;
}

Publishing the Event: publishEvent() takes the URL, JSON body and SESSION ID as the parameters and method will return the response object which will be stored in the reference variable "response". This variable later can be used to validate the response code which in this case is 200. Along with that, you need to fetch the "sessionId" from the response which you need to Publish the event later.

public void iPerformsAPublishEventRequest() throws Throwable {
    try {
        Response response = SampleUtil.publishEvent("http://publisheventurl:8080",jsonBody,sessionId);
        assertEquals(responseCode, response.code());
    } catch (Exception e) {
        System.out.println(e.getMessage());
    }
}

SampleUtil.java Code:
public static Response publishEvent(String url, String jsonBody, String sessionId) {
    try {
        RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), jsonBody);

        OkHttpClient client = new OkHttpClient();
        okhttp3.Request request = new okhttp3.Request.Builder()
                .url(url)
                .post(body)
                .addHeader("sessionId", sessionId)
                .build();
        return client.newCall(request).execute();

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

Wednesday 27 June 2018

Winning Tactics For Crossing The Bridge Puzzle




Puzzle 2➤ Crossing the Bridge riddle 
There are 4 persons (A, B, C, and D) who want to cross a bridge in the night.
  • A takes 1 minute to cross the bridge.
  • B takes 2 minutes to cross the bridge.  
  • C takes 5 minutes to cross the bridge.
  • D takes 10 minutes to cross the bridge.
There is only one torch with them and the bridge cannot be crossed without the torch. There cannot be more than two persons on the bridge at any time.
What is the shortest time needed for all four of them to cross the bridge?

The Answer To The Puzzle 2➤


This is a popular question asked during the interviews. So we need some thought process to find out the winning solution.

The thought process to decide upon the optimum strategy:


  • Always make sure that the 2 persons together cross the bridge towards their camp.
  • Ensure that the fastest available person on the camp side to bring the torch to the other side.
  • Ensure that none of the two slowest persons among the four of the team (in this case the 5 & the 10) cross the bridge more than once. So they can't be allowed to cross the bridge in the first trip as well as on the last trip.
  • So, in the first trip, the two fastest persons in the team (in this case, the 1 and the 2) cross the bridge towards their camp. And, any one of them (ie either 1 or 2) comes back and hands over the torch to 5 and 10.
  • Once they arrive at camp, 2 or 1 (as the case may be), brings to rescue 1 or 2 (as the case may be).

So, The final plan➤

  • 1 & 2 cross; 1 OR 2 remains; 2 OR 1 returns=> Time taken: 2+2=4' OR 2+1=3'.
  • 5 & 10 arrives at camp and remain there. 1 OR 2 returns=> Time taken: 10+1=11 OR 10+2=12'.
  • 1 AND 2 arrive at camp=>Time taken=2'

Total Time To Cross The Bridge ➤

Total Time Taken➤ 4+11+2=17'        OR         Total Time Taken➤ 3+12+2=17'

Sunday 11 March 2018

Cracking The Puzzle Code - Top Puzzles Asked During Interviews

Puzzles are the big part of the interview process especially for the person who is going to QA, SDET, Developer or programmer positions.

Puzzles are to test out software engineer's analytics and logical thinking ability. It's not a hard and fast rule to ask the puzzles during the interview but now these days most of the startups and top tech companies have started the trend of asking such brain teasers and riddles and during the interviews.

Better be prepared for such scenarios, solving a couple of puzzles before your interview will give a boost to you and your brain and will be helpful in tackling similar questions related to puzzles when asked during your interview.

So let's get started Braining:



Top Tech Puzzles:

Puzzle 1: When is Cheryl's birthday?

Puzzle 2: Winning Tactics For Crossing The Bridge Puzzle






Here is How To Verify The Broken and Loaded Image In The Page

You might have faced scenarios where you had to verify the images loaded completely on the page or loaded broken. Doing it manually could be one way but it may become difficult if you have to actually verify the images is loaded using Automation, but Selenium has the solution for this problem.


Let's see how we can validate broken and loaded images :

So what you can do is use JavaScriptExcecutor interface which has a method executeScript(). You can check if the image is getting displayed or not by calling the executeScript method of the  JavaScriptExcecutor Interface.

public void verifyImageLoaded(String imageSrc){
    WebElement image = driver.findElement(By.xpath("//img[@src='"+imageSrc+"']"));
    Object checkResult = ((JavascriptExecutor) driver).executeScript(
            "return arguments[0].complete && "+
                    "typeof arguments[0].naturalWidth != \"undefined\" && "+
                    "arguments[0].naturalWidth > 0", image);

    boolean loaded = false;
    loaded = (Boolean) checkResult;
    Assert.assertTrue("Image was not rendered properly", loaded);
}

This method validates if the image with the given source has been loaded completely or not. checkResult will be returned as an object so to get the Boolean value you need to typecast checkResult to fetch the boolean value.

To Validate Broken Image: To check if the method works fine with broken images, just try to send the wrong URL for the image source and the method will fail at the Assert statement with the false value for the 'loaded' variable. The broken image looks something like below image :


Try the code and write to me if you face some issue.

Learning Selenium Can Be Addictive. Get Yourself Hooked

Learning test automation is possible for everyone—remember that even the greatest programmers know nothing about coding initially 😊

So, first of all, have faith in you and that is the Key. Having a good plan to learn something, to be successful, one should also be clear about their goals.
So let's understand why Automation is needed in the first place:

You might have observed that the most of the applications are Web-Based Applications, i.e the applications which can be accessed using browsers (Chrome, Firefox, Safari etc.). Applications now these are highly interactive and rapidly changing and getting developed at much pace as compared to earlier times. So some kind of mechanism was needed to test this fast-changing environment and displaying test results at the similar speed so that development process can be carried out.

So Automation was the way to handle such task, such as a repetitive test of a particular module, which could have been a cumbersome job for a manual tester. Imagine a time where you could be testing the same thing over and over again daily just to verify that it is working fine. How about automating such scenarios and execute it in just one click 😉

Yes, Automation will save hell lot of time, energy and mental stress of meeting the deadlines. One can simply schedule their test cases to execute them daily, multiple time in a day or on the need basis.
So how to make learning Selenium Addictive:

Clear Your Mind: First thing that you need to do is to clear your all the negative thoughts about Coding, Thoughts like :
             1. This coding language is very tough.
             2. I have not done any coding, I am just a manual tester
             3. I can't learn Java, there are so many things in JAVA

Thoughts above will first kill your confidence and then your faith in you. Do not let anyone put anything negative in your mind. You should be the one to decide what has to be done and how it should be done.


Pick The Language:  Selenium is nothing but simply calling action methods on the buttons, text fields, links, checkboxes etc. You do not need to be a master of a language to learn Selenium. Simple basic concepts will be good enough for anyone to work with Selenium. And when you will get the groove of it you will be easily able to understand in and out of the Selenium. 




Dirty Your Hands: If you are feeling hungry and then you just picked up a cooking book and start reading it. Will it help you to put down your hunger?. Simply reading article and topics of Selenium won't help you at all. You have to make your hands dirty with the code. Seeing the code and writing one down will make a huge difference in your learning process.

Take A Break: Rome was not built in a day similarly learning is not a one-day process, you have to improve gradually. Break your learning sessions and better you divide your topics according to the difficulty levels.



Learn Every Day: Increase your knowledge daily basis. Spend at least 30-60 mins daily on new topics or revision of the things already learned.  





Monday 2 October 2017

Selenium Super 30 Interview Questions - 3

21. How would you make sure that a particular feature is enable or disabled in the browser launched or how would launch a browser with some specific properties.
  • FirefoxProfile profile = new FirefoxProfile();
  • profile.setPreference("browser.startup.homepage", "http://www.google.com");
  • driver = new FirefoxDriver(profile);
22. What are the limitations with IE browser? What are the things that have to be done before actually using the IE browser for the automation?
·        If you see issue something like 'Unexpected error launching Internet Explorer' below, you have to set 'Enable protected mode' option in all levels with same value.
·        2. Make sure that the IE browser zoom level is set to 100% so that the native mouse events can be set to the correct coordinates.
·        3. It may be silly one, But make sure you provide correct path when setting the property of Internet explorer driver.
23. How would you locate a Frame without ID or Name?
  • WebElement frame = driver.findElement(By.xpath(<your frame xpath>));
driver.switchTo().frame(frame);
  • driver.switchTo().frame(driver.findElement(By.cssSelector("iframe[title='Fill Quote']")))
24. Is it possible to migrate from selenium RC to Webdriver. Can I execute the scripts written in RC using webdriver. If yes how can we achieve the same?
Yes, it’s possible to migrate.
The first step when starting the migration is to change how you obtain your instance of Selenium. When using Selenium RC, this is done like so:
Java Code:
Selenium selenium = new DefaultSelenium(
    "localhost", 4444, "*firefox", "http://www.yoursite.com");
selenium.start();
This should be replaced like so:
Java Code:
WebDriver driver = new FirefoxDriver();
Selenium selenium = new WebDriverBackedSelenium(driver, "http://www.yoursite.com");
Next Steps
Once your tests execute without errors, the next stage is to migrate the actual test code to use the WebDriver APIs. Depending on how well abstracted your code is, this might be a short process or a long one. In either case, the approach is the same and can be summed up simply: modify code to use the new API when you come to edit it.
If you need to extract the underlying WebDriver implementation from the Selenium instance, you can simply cast it to WrapsDriver
Java Code:
WebDriver driver = ((WrapsDriver) selenium).getWrappedDriver();
This allows you to continue passing the Selenium instance around as normal, but to unwrap the WebDriver instance as required.
At some point, you’re codebase will mostly be using the newer APIs. At this point, you can flip the relationship, using WebDriver throughout and instantiating a Selenium instance on demand:
Java Code:
Selenium selenium = new WebDriverBackedSelenium(driver, baseUrl);
25. How to check if a text is highlighted on the page?
  • String color = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("color");
  • String backcolor = driver.findElement(By.xpath("//a[text()='Shop']")).getCssValue("background-color");
  • System.out.println(color);
  • System.out.println(backcolor);
26. WebDriver is a class or interface? If interface name few of the methods which are part of the webdriver interface. Name the classes which have done the implementation from this interface.
WebDriver is Interface.
Methods: close(), findelememt(By by), findelemetns(By by), quit(), switchto() etc.
27. What is Page object Model? What is page factory? How would you initialize the webelements in Page Object Model?
     
·        Page Object Model is a design pattern to create Object Repository for web UI elements.
·        Under this model, for each web page in the application there should be corresponding page class.
·        This Page class will find the WebElements of that web page and also contains Page methods which perform operations on those WebElements.
Advantages of POM
·        Page Object Patten says operations and flows in the UI should be separated from verification. This concept makes our code cleaner and easy to understand.
·        Second benefit is the object repository is independent of testcases, so we can use the same object repository for a different purpose with different tools. For example, we can integrate POM with TestNG/JUnit for functional testing and at the same time with JBehave/Cucumber for acceptance testing.
·        Code becomes less and optimized because of the reusable page methods in the POM classes.
PageFactory
·        The PageFactory Class is an extension to the Page Object design pattern. It is used to initialize the elements of the Page Object or instantiate the Page Objects itself. Annotations for elements can also be created (and recommended) as the describing properties may not always be descriptive enough to tell one object from the other.
·        It is used to initialize elements of a Page class without having to use ‘FindElement’ or ‘FindElements’.
PageFactory.initElements(driver, PageName.class);
28. How would you count the number of rows of a given table?
·        //To locate table.
WebElement mytable = driver.findElement(By.xpath(".//*[@id='SomeID']/div[1]/table/tbody"));
·        //To locate rows of table.
List<WebElement> rows_table = mytable.findElements(By.tagName("tr"));
·        //To calculate no of rows In table.
int rows_count = rows_table.size();
29. Write the sequence of steps to delete a particular row (with user name = "xyz") in a table with multiple pages. One page contains max of 10 rows.
  
        Steps should include:
·        Locate the table
·        Locate the rows
·        Find a row with a user name “xyz”
·        If the user name is not present in the first page it should navigate to the next page
·        Repeat first 3 steps again till the row with username = “xyz” is found.
·        Delete the row.
 
30. Why do we need a Maven? What is the purpose of creating our own framework when selenium has already provided the APIs? Why do we need a framework?
Maven: Maven’s primary goal is to allow a developer to comprehend the complete state of a development effort in the shortest period of time. In order to attain this goal there are several areas of concern that Maven attempts to deal with:
·        Making the build process easy
·        Providing a uniform build system
·        Providing quality project information
·        Providing guidelines for best practices development
·        Allowing transparent migration to new features
As part of the Automation framework it’s easy to add/update tools/APIs according to the latest versions available. We just need to configure the POM and build it. All the required jars will be added to the framework automatically.
Framework:
Automation framework is a way to organize your code in much meaningful manner, so that any person who is luckily working with you should understand what each file has and what is the purpose of adding the file.
A TEST Automation Framework is a set of guidelines like coding standards, test-data handling, object repository treatment etc., which when followed during automation scripting produce beneficial outcomes like increase code re-usability, higher portability, reduced script maintenance cost etc.

Selenium Super 30 Interview Questions - 2

 

11. Out of 100 check-boxes listed in the page you have to select a particular check-box with text = "abc". Sequence of check-boxes may change from time to time. Consider check-boxes and text in a tabular form.

One possible solution would be xpath:

selectCheckboxWithLabel(NameofLabel){

driver.findElement(By.xpath

        (".//*[@id='main']/table[1]/tbody/tr/td[2][text()=' NameofLabel ']//preceding-sibling::input[1]")).click

  }

12. Write the sequence of steps required to achieve the following:

In first window click on the link. This will open a new window. Enter some data into the text field and clicks submit. Close the second window and come back to the first window.

Click some button on first window and close it.

 Steps should include:

1.      Click on the link present on the main window

2.      Save the handler for the first window before switching to the new window.

3.      Switch to the new window.

4.      Enter some data on the text field and click submit

5.      Close the second window.

6.      Switch back to the main window before accessing any element on that window.

7.      Close the window.

13. Write the sequence of steps to access the element present in a Frame within a Frame.

                              WebElement OuterFrame = driver.findElement(By.id("Frame1")); 

                              //now use the switch command

                              driver.switchTo().frame(OuterFrame); 

                              //Find Frame2

                              WebElement InnerFrame = driver.findElement(By.id("Frame2"));

                              //now use the switch command

                              driver.switchTo().frame(InnerFrame);

                              //Switch back to the main window

                              driver.switchTo().defaultContent();

14. How to automate/capture the mouse hovering sequence. Write the steps

WebElement element = driver.findElement(By.linkText("Product Category"));

Actions action = new Actions(driver);

action.moveToElement(element).moveToElement(driver.findElement(By.linkText("linktext"))).click().build().perform();

15. How one can upload the file without using any external tool in selenium web-driver.

driver.findElement(By.xpath(“input field”)).sendKeys(“path of the file which u want to upload”);

16. Difference between web-based and window-based pop-up. How one can handle these pop-ups.

There are two types of alerts that we would be focusing on majorly:

1.    Windows based alert pop ups( Like Print Dialog )

2.    Web based alert pop ups (Alert box/ Pop up box/ confirmation Box/ Prompt/ Authentication Box)

As we know that handling windows based pop ups is beyond WebDriver’s capabilities, thus we need  some third party utilities to handle window pop ups(like Autoit, Robot etc.)

Handling web based pop-up box

WebDriver offers the users with a very efficient way to handle these pop ups using Alert interface.

There are the four methods that we would be using along with the Alert interface.

1) void dismiss()  The dismiss() method clicks on the “Cancel” button as soon as the pop up window appears.
2) void accept()  The accept() method clicks on the “Ok” button as soon as the pop up window appears.
3) String getText()  The getText() method returns the text displayed on the alert box.
4) void sendKeys(String stringToSend)  The sendKeys() method enters the specified string pattern into the alert box.

 

Object Creation for Alert class:

v  Alert alert = driver.switchTo().alert();

We create a reference variable for Alert class and references it to the alert.

v  Switch to Alert
Driver.switchTo().alert();
The above command is used to switch the control to the recently generated pop up window.

v  Accept the Alert
alert.accept();
The above command accepts the alert thereby clicking on the Ok button.

v Reject the Alert
alert.dismiss();
The above command closes the alert thereby clicking on the Cancel button and hence the operation should not proceed.

17. How would you test a Captcha Code? Is it possible to test it?

Captcha code was introduced in order to prevent from the robot or automation codes. There is no option for automating the Captcha code.

v  You can give a wait time for the automation, so that the user can enter the captcha code.

v  If the project is in testing URL means, you can request your system admin and developer to disable the captcha validation.

Developers will generate a random value for captcha, and they will convert the value into image as well as they will store the value in session for comparing the entered input is matching with the captcha code.

So If possible, you can take that session value and give as the input.

Usually most of the companies either use their own captchas or one of the third party captchas (GooglejQuery plugins) in the user registration page of their sites .So these pages can't be automated fully. In fact Captcha itself is implemented to prevent automation. As per official captcha site

A CAPTCHA is a program that protects websites against bots  by generating and grading tests that humans can pass but current computer programs cannot.

Captchas are not breakable but there are some third party captchas that can be breakable and one of the example for it is "jQuery Real Person" captcha .

18. How would you take a screen shot for the failed test case? How does it work and where have you kept your code to capture the code in your framework?

In order to take screenshot in case of test failure we will use AfterMethod annotation of TestNG. In the AfterMethod annotation we will use ITestResult interface's getStatus() method that returns the test result and in case of failure we can use the above commands to take screenshot

@AfterMethod

public void takeScreenShotOnFailure(ITestResult testResult) throws IOException {

               if (testResult.getStatus() == ITestResult.FAILURE) { System.out.println(testResult.getStatus());

                              File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);

                              FileUtils.copyFile(scrFile, new File("D:\\testScreenShot.jpg"));

    }

}

Location of this code depends on framework to framework. We need to dig more and get the design and location for screenshot based on their framework.

19. How are you reading the data from excel. Where are you keeping your data read from the excel when executing the test cases. How are you managing to execute the same test case with different set of data?

1.        FileInputStream fis = new FileInputStream(“path of excel file”);

    Workbook wb = WorkbookFactory.create(fis);

    Sheet s = wb.getSheet(“sheetName”);

    String value = s.getRow(rowNum).getCell(cellNum).getStringCellValue();

2.      Depends on framework to framework how where and how candidates are storing the data. Whether its Array List or HashMap candidate should be able to explain their logic and write a dummy code for the same.

3.      Should explain Logic to execute same test case with different data or TestNG annotation to achieve the same functionality.

20. Difference between findelement and findelements. What are their return types?

  • findElement() method:

ü  We need to use findElement method frequently in our webdriver software test case because this is the only way to locate any element in webdriver software testing tool.

ü  findElement method is useful to locating targeted single element.

ü  If targeted element is not found on the page then it will throw NoSuchElementException.

  • findElements() method:

ü  We are using findElements method just occasionally.

ü  findElements method will return list of all the matching elements from current page as per given element locator mechanism.

ü  If not found any element on current page as per given element locator mechanism, it will return empty list.