• Slider Banner

    Prepare for

    Technical Interview

    Over .1 Million+ Interview Questions for different profiles

    Read More
  • Slider Banner

    Join the

    Programming World

    Learn about top programming languages, tools and frameworks.

    Read More
  • Slider Banner

    Prepare with

    Certification MCQ

    Practice for certification from 1000+ multiple choice questions.

    Read More

What are the multiple ways to click on Submit button in Selenium?

Here are the list of techniques:

.click() method: You can use .click() method to click on any button of software web application. Means element's type = "button" or type = "submit", .click() method will works for both.

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.click();

.submit() method: If you will look at firebug view for any form's submit button then always It's type will be "submit". In this case, .submit() method Is very good alternative of .click() method.

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.submit();

Keys.Enter: 

WebElement myButton = driver.findElement(By.cssSelector("locator"));
myButton.sendKeys(Keys.ENTER);

Action Class:

WebElement myButton = driver.findElement(By.cssSelector(locator));
Actions builder = new Actions(driver);
    builder
        .moveToElement(myButton)
        .click()
        .build()
        .perform();

JavaScriptExecutor:

WebElement myButton = driver.findElement(By.cssSelector(locator));
JavascriptExecutor js = (JavascriptExecutor)driver;		
js.executeScript("arguments[0].click();", myButton);

Can we use Selenium Grid with JMeter for Performance testing?

Yes its possible. You need to install Selenium/Webdriver Support plugin.

Also add, Logic Controller -> jp@gc-Remote Driver Config, Simple Controller and Sampler -> jp@gc WebDriver Sample.

In Remote Driver Config and write your selenium grid URL. You should change 127.0.0.1 to your real existing selenium grid server IP/url. Change capability to Chrome. If you want to use different browser, you must reRegister node to Grid Hub with different settings.

What are the challenges with Rest Assured?

Below is the list of Challenges with Rest Assured:

Language Support: Support only Java Language.

Not Easy to learn: Implementation is not easy. Good Java knowledge required.

Performance Testing: Not integrated with tool.

What are the challenges with PageFactory?

Below are the challenges with PageFactory:

No of Pages: If there is an application with hundreds or thousands of web pages then the time and the effort in the development of automation framework will be high.

Maintenance Overhead: The cost increases when maintenance overhead increases which are due to the maintenance of large class as they break the OO design principle.

Programming Best Practices: The development of POM framework for multiple pages is equal to developers work thus testers should be highly knowledgeable in programming best practices.

Not Generic Model: Page object model is not a generic model and its specific to the applications.

The best approach to overcome the above challenges is by refactoring the POM concept to Screenplay Pattern.

What are different API Optimisation Techniques?

Below are the different techniques:

Compression Techniques: Use JSON serializer and gZip compress techniques for the data transmitted over the web.
Use faster data access strategies
Caching: Have heard somewhere that the "fastest HTTP call is the one that you don't make" that is, use caching(Memcache/Redis), most of the requests are read operations, wise use of cache control headers are also useful. That spares the database from serving repeated read requests which are expensive. (Not sure if Etags can be of any use ?)
Use asynchronous methods judiciously
make as few API calls as possible
Programming level: use code optimization/threading/parallel programming.
Geography: Account for the distance between end users and origin servers, we can use CDNs for storing the static contents of the response, so that it can be served real fast.
API level: use pagination/filters/ranges to generate fine-grained data that is tailored to the need of the client.

What are checked and unchecked Exception in Java?

Checked Exception: are the exceptions that are checked at compile time. If some code within a method throws a checked exception, then the method must either handle the exception or it must specify the exception using throws keyword.

  • FileNotFoundException
  • IOException
  • ClassNotFoundException
  • SQLException 
  • DataAccessException
  • InvocationTargetException
  • MalformedURLException

Unchecked Exception: Unchecked are the exceptions that are not checked at compiled time. 

  • NullPointerException
  • ArrayIndexOutOfBound
  • IllegalArgumentException
  • IllegalStateException
  • IllegalStateException

If Timeout of Explicit wait is 30 Seconds and Timeout for Implicit Wait is 60 seconds, Consider element is not found then for how much time script will wait before the exception is thrown.

Case 1: When Implicit Wait > Explicit Wait. For Example Implicit Wait is 60 seconds and Explicit Wait is 30 Seconds.

Then, Script will wait for 60 seconds.

Case 2: When Explicit Wait > Implicit Wait. For Example Implicit Wait is 20 seconds and Explicit Wait is 40 Seconds.

Then, Script will wait for 40 seconds.

What is return type of TestNG Data Provider?

Data provider returns a two-dimensional JAVA object to the test method and the test method, will invoke M times in a M*N type of object array. For example, if the DataProvider returns an array of 2*3 objects, the corresponding test case will be invoked 2 times with 3 parameters each time.

Example:

/**
   * @return Object[][] where first column contains 'author'
   * and second column contains 'Country'
*/

    @DataProvider(name="SearchProvider")
    public Object[][] getData()
    {
        return new Object[][]
        {
            { "Ram", "India" },
            { "Sham", "UK" },
            { "Mohan", "USA" }
       };
    }
Subscribe to