How to change Java JDK Version of IntelliJ IDEA.

Open IntelliJ IDEA. Then from top menu click File>Project Structure

Then you can change the values.

To see the changes are applied, you can create a class file in the project and run below code.

public class VersionChecker{

public static void main(String[] args) {
Runtime.Version myversion =Runtime.version();
System.out.println("My Java version is--"+myversion);
}
}

The output is

My Java version is — 18.0.2+9–61

--

--

Webdriver how to verify element is not displayed in Java.

This code snippet can be used when there is a hard coded element.

// WebElement first search result link can be captured using search_results_scroll.
boolean isDiplayedKnowledgeBase=false;
WebCommand.pause(6000);
try{
WebElement firstSearchResult = search_results_scroll.findElement(By.cssSelector("ul > li"));
isDiplayedKnowledgeBase=firstSearchResult.isDisplayed();
}
catch(NoSuchElementException e){
System.out.println("Unwanted element is not displayed.");
}
Assert.assertEquals(false, isDiplayedKnowledgeBase,"This facility is listed for unwanted users.");

If the element is passed form page object model can use below code snippet.

Pass the element from the page Object

elementNotPresentVerification(gatewayLandingPage.lbl_WhatNeedTohappenWithThis);public void elementNotPresentVerification(WebElement element) {
try {
Assert.assertEquals(false, element.isDisplayed(), "Unwanted element is displayed " + element);
} catch (NoSuchElementException e) {
System.out.println("Unwanted element is not found");
}
}

--

--

Install open JDK 18 and Maven in Windows 10.

Just download open JDK, latest version.
https://jdk.java.net/18/

Unzip it and create a folder called Java in C:\Program Files, and move the extracted files in to ,C:\Program Files\Java

Then set system variables as below.

path
C:\Program Files\Java\jdk-18.0.2\bin

JAVA_HOME
C:\Program Files\Java\jdk-18.0.2

CLASSPATH
C:\Program Files\Java\jdk-18.0.2\bin

Below commands should work.

java -version

javac -version

jshell

Then download maven, binaries apache-maven-3.8.6-bin.zip from https://maven.apache.org/download.cgi
Extract the file and create folder without spaces in C: drive. Example, C:\Maven and move the extracted files.

Go to system variables and add
MAVEN_HOME
C:\Maven\apache-maven-3.8.6

After that in path variable , create new and add this .
%MAVEN_HOME%\bin

Open a command line and type
mvn -version

--

--

GIT clone a repository based on commit.

Assume that one of the files you needed were deleted accidently and already committed to the current branch and on top of that you had done several commits. However, still you need to get that deleted file.

First identify the commit that just prior to the deletion of the file.

Easy way is identify via GITLAB.

So it’s 91ae3305c61ce8803148dfcdc788ec5d2a6c7ecc

Then to a new location, clone the particular branch using GIT CLI.

git clone -b MybaranchName --single-branch https://github.com/Org/Project.git

Then type below command to get the branch in the commit.

git checkout 91ae3305c61ce8803148dfcdc788ec5d2a6c7ecc

Using this can get the branch in that commit.

--

--

How to pass WebElement type to JavascriptExecutor

The code is given below.

// Define the JavascriptExecutor.JavascriptExecutor js = (JavascriptExecutor) driver;//Capture the element using any locator strategy.WebElement element =driver.findElement(By.name("btnLogin")); //Perform Click on LOGIN button using JavascriptExecutor

js.executeScript("arguments[0].click();", element);

--

--

How to capture a tag in same level using Sibling “+” Operator CSS Selector in Selenium.

Problem scenario

I want to capture this input tag, located in div tag, but in the same level of span.

How to do it ?

First of all capture the div that span…

--

--

How to get maven dependency of a maven project in command line.

Steps-

In windows, Go inside of the folder that pom.xml exists

Then type

mvn dependency:tree --log-file log.txt

Generated log.txt file contains all the dependency information.

[INFO] +- org.testng:testng:jar:7.3.0:compile
[INFO] | +- com.beust:jcommander:jar:1.78:compile
[INFO] | +- org.apache.ant:ant:jar:1.10.3:compile
[INFO] | | \- org.apache.ant:ant-launcher:jar:1.10.3:compile
[INFO] | +- junit:junit:jar:4.12:compile
[INFO] | | \- org.hamcrest:hamcrest-core:jar:1.3:compile
[INFO] | +- com.google.inject:guice:jar:no_aop:4.2.2:compile
[INFO] | | +- javax.inject:javax.inject:jar:1:compile
[INFO] | | \- aopalliance:aopalliance:jar:1.0:compile
[INFO] | \- org.yaml:snakeyaml:jar:1.21:compile
[INFO] +- org.projectlombok:lombok:jar:1.18.20:compile

Image-

--

--