How to compare ArrayLists – containsAll method?

HOME

package com.example;

import java.util.ArrayList;
import java.util.Arrays;

public class ContainsAll_ArrayList {

    public static void main(String[] args) {

        ArrayList<String> list1 = new ArrayList<String>();

        list1.add("Java");
        list1.add("Python");
        list1.add("PHP");
        list1.add("JavaScript");
        list1.add("Ruby");


        ArrayList<String> list2 = new ArrayList<>(Arrays.asList("Python", "Ruby"));
        ArrayList<String> list3 = new ArrayList<>(Arrays.asList("Python", "Java", "Ruby", "PHP", "JavaScript"));

        System.out.println("ArrayList1:" + list1);
        System.out.println("ArrayList2:" + list2);

        // check if ArrayList 1 contains ArrayList 2 (ArrayList 2 is subset of ArrayList 1)
        System.out.println("Check arrayList1 containsAll arrayList2 :" + list1.containsAll(list2));

        // check if ArrayList 2 contains ArrayList 1 (ArrayList 2 is subset of ArrayList 1)
        System.out.println("Check arrayList1 containsAll arrayList2 :" + list2.containsAll(list1));

        // check if ArrayList 1 contains ArrayList 3 (different sequence)
        System.out.println("Check arrayList1 containsAll arrayList3 :" + list1.containsAll(list3));

        }
}

list1.containsAll(list2));
list2.containsAll(list1));
list1.containsAll(list3));

Cucumber Multiple Choice Answers – MCQ1

HOME




@LoginPage
Feature: Login to HRM Application
  
   @ValidCredentials
   Scenario: Login with valid credentials
     
   Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
    When User enters username as "Admin" and password as "admin123"
    Then User should be able to login successfully and new page open

import org.junit.runner.RunWith;
import io.cucumber.junit.Cucumber;
import io.cucumber.junit.CucumberOptions;
 
@RunWith(Cucumber.class)
@CucumberOptions(plugin = "pretty", features = "src/test/resources/Features/MyHoliday.feature", tags = "@BookOneWayFlight")
 
public class CucumberRunnerTest {
 
}










Feature: Login to HRM Application
 
  Background:
    Given User is on HRMLogin page "https://opensource-demo.orangehrmlive.com/"
 
  @ValidCredentials
  Scenario: Login with valid credentials
 
    When User enters username as "Admin" and password as "admin123"
    Then User should be able to login successfully and new page open
 
  @MissingUsername
  Scenario: Login with blank username
 
    When User enters username as " " and password as "admin123"
    Then User should be able to see a message "Required" below Username










Cucumber Multiple Choice Questions – MCQ1

HOME

Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer

====================================================================

How to set Proxy in Firefox using Selenium

HOME

FirefoxOptions options = new FirefoxOptions();
options.addPreference("network.proxy.type", 1);
options.addPreference("network.proxy.http", proxyAddress);
options.addPreference("network.proxy.http_port", proxyPort);

driver = new FirefoxDriver(options);

package org.example;

import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.firefox.FirefoxOptions;

public class FireFoxProxyDemo {


    public static void main(String[] args) {

        // Set the proxy server details
        String proxyAddress = "localhost";
        int proxyPort = 8080;
        FirefoxDriver driver;

        // Create an instance of `FirefoxOptions` and set the proxy configuration
        FirefoxOptions options = new FirefoxOptions();
        options.addPreference("network.proxy.type", 1);
        options.addPreference("network.proxy.http", proxyAddress);
        options.addPreference("network.proxy.http_port", proxyPort);

        // Instantiate FireFox Driver with the configured options
         driver = new FirefoxDriver(options);

        // Perform your browsing actions using the driver
        driver.get("https://www.google.com");
        System.out.println("Page Title :" + driver.getTitle());

        // Close the browser session
        driver.quit();
    }
}

Multiple Choice Questions

HOME

  1. Programming Languages
    1. Java
  2. Test Automation Frameworks
    1. Selenium
    2. Advance Selenium
    3. Robot Framework
    4. JUnit4
    5. TestNG
  3. API Testing
    1. Rest API
    2. Pytest Framework
  4. DevOps & Continuous Integration/Continuous Deployment (CI/CD)
    1. DevOps
    2. Jenkins
  5. Version Control Systems
    1. Git
    2. GitHub
  6. Containerization
    1. Docker
  7. Database
    1. SQL
  8. Types of Testing
    1. Security Testing
    2. Performance Testing
    3. ETL Testing

Jenkins Multiple Choice Questions – MCQ1
Jenkins Multiple Choice Questions – MCQ2

GitHub Multiple Choice Questions – MCQ1

Docker – Basic Level – Multiple Choice Questions and Answers – MCQ1
Docker – Advance Level – Multiple Choice Questions and Answers – MCQ1

Selenium Multiple Choice Answers – MCQ3

HOME

Selenium Multiple Choice Questions – MCQ3

























Selenium Multiple Choice Questions – MCQ3

HOME

Selenium Multiple Choice Questions – MCQ1

Selenium Multiple Choice Questions – MCQ2















Actions a=new Actions(driver);

Answer


Answer


Answer


Answer

Answer


Answer


Answer


Answer


Answer


Answer


Answer

==============================================================

Selenium Multiple Choice Questions – MCQ1
Selenium Multiple Choice Questions – MCQ2
Advance Selenium Multiple Choice Questions – MCQ1
Advance Selenium Multiple Choice Questions – MCQ2

Selenium Multiple Choice Questions – MCQ2

HOME


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


//li[@id='firstItem']//following::a

Answer


//li[@id='firstItem']//child::*

Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer

Selenium Multiple Choice Questions – MCQ1

HOME

Answer


Answer


Answer


Answer


WebDriver driver=new WebDriver();

Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


Answer


1. WebElement element = driver.findElement(By.xpath("//[contains(text(), ' QAAutomation')]"));

2. WebElement element = driver.findElement(By.xpath("//[(text(), ' QAAutomation')]"));

3. WebElement element = driver.findElement(By.xpath("\*[contains(text(), ' QAAutomation')]"));

4. None

Answer


1. driver.navigate(“https://www.qaautomation.expert”);

2. driver.navigate.to(“https://www.qaautomation.expert”);

3. driver.navigate.url(“https://www.qaautomation.expert”);

4. None

Answer


i. navigate().to("url")
ii. open("url")
iii. goTo("url"
iv. get("url")

Answer


Answer


Answer


Answer


Answer


Answer


Answer

====================================================================

Selenium Multiple Choice Questions – MCQ2

Selenium Multiple Choice Questions – MCQ3

How to set Proxy in Chrome using Selenium

HOME

     // Set the proxy server details
        String proxyAddress = "proxy.example";
        int proxyPort = 8080;

        // Create a Proxy object and set the HTTP proxy details
        Proxy proxy = new Proxy();
        proxy.setHttpProxy(proxyAddress + ":" + proxyPort);

ChromeOptions options = new ChromeOptions();
options.setProxy(proxy);
WebDriver driver = new ChromeDriver(options);

import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;

public class ProxyDemo {

    public static void main(String[] args) {

        // Set the proxy server details
        String proxyAddress = "localhost";
        int proxyPort = 8080;

        // Create a Proxy object and set the HTTP proxy details
        Proxy proxy = new Proxy();
        proxy.setHttpProxy(proxyAddress + ":" + proxyPort);

        // Configure Chrome options with the Proxy object
        ChromeOptions options = new ChromeOptions();
        options.setProxy(proxy);
        options.addArguments("start-maximized");

        // Instantiate ChromeDriver with the configured options
        WebDriver driver = new ChromeDriver(options);


        // Perform your browsing actions using the driver
        driver.get("https://www.google.com");
        System.out.println("Page Title :" + driver.getTitle());

        // Close the browser session
        driver.quit();
    }
}