Java File.separator example.

Different operating systems use different characters as file and path separators. When our application has to run on multiple platforms, we need to handle these correctly.
To handle this requirement we can use Java provide File.separator.

This is an example of used / at start and the…

--

--

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{…

--

--

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){…

--

--

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…

--

--

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…

--

--

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);

--

--

--

--