How to upload a file in remote webdriver.

In this example, let’s look at the possibility of attaching an image to JIRA.

Code is as per below-

import org.openqa.selenium.remote.LocalFileDetector;
import org.openqa.selenium.remote.RemoteWebDriver;

((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
String filePath = System.getProperty("user.dir") + "/src/Attachments/SnowAttachment.png";
WebElement element = findElements(By.xpath("//element[@attribute='value']"));



Import the parent project to the IntelliJ IDEA as a new module.

First import the child project, then click , File > New > Project from existing source

and select the parent project.

Click Next, by selecting create project from existing sources.



How to close the second tab once it’s functionality is done , in Webdriver Java.

The code is

public static void closeSecondTabAndSwitchToFirstTab(WebDriver driver){
ArrayList<String> tab = new ArrayList<String> (driver.getWindowHandles());
System.out.println("No of tabs are --"+tab);
if (tab.size() == 1) {
System.out.println("No additional tabs.");
} else {
//Close the second window.
System.out.println("Closed the second tab using index 1.");
System.out.println("Switched to main window using index 0.");



IntelliJ IDEA takes ages to update the indices.

When I opened my IntelliJ IDEA, it says updating indexes but even after an hour , it’s still updating how to solve this .

Open IntelliJ IDEA, save all your code.

Select options as below and click Invalidate and Restart



How to access Test plan’s keys (variables) using ISuite suite.

Recently, I had a requirement to get a value from Test plan xml file to a onStart method in SuiteListener class which implements ISuiteListener

public class SuiteListener implements ISuiteListener {
@Override//This is equal to before Suite.
public void onStart(ISuite suite) {

To solve that I used suite.getAttribute method.

public void onStart(ISuite suite) {
String value = (String) suite.getAttribute("browserVersion");
String browserVersion= suite.getXmlSuite().getParameter("browserVersion");
System.out.println("browserVersion is "+browserVersion);

So it’s output the below output.

browserVersion is 95

My Test plan is like below.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "">
<suite thread-count="2" name="Problem-Management-Suite" parallel="tests">
<listener class-name="com.sam.reporting.SuiteListener" />
<listener class-name="com.sam.reporting.Listeners" />
<parameter name="browser" value="Chrome" />
<parameter name="browserVersion" value="95" />
<test name="test name-01">
<class name="com.sam.testcases..TC_01"/>
</test> <!-- Test -->




Get current date time in a defined format with IST time zone

For that could use below code in Java 1,8 or above.

public static  String  getCurrentDate(){
final ZonedDateTime now ="Asia/Kolkata"));
String Temporal= DateTimeFormatter.ofPattern("yyyy-MM-dd").format(now);
String today=;
return today;

pattern can be further modified. Here it’s return time as well.

String Temporal= DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss").format(now);

Output is

2021–11–05 17:51:50

A list of time zones could be retrieved from