Using Katalon's Web Driver element

Hello there,
I’ve created a login test for my app using Java and I also managed to run it via Katalon-Studio. This is my script:

System.out.println("\n*** Login ***\n");
//Initializing server
System.setProperty("webdriver.chrome.driver", "C:/selenium/chromedriver.exe");
ChromeDriver wd = new ChromeDriver();
wd.manage().window().maximize();
wd.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

//login
wd.get("<URL>");
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("<email>");
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("<password>");
wd.findElement(By.xpath("//form[@id='form']//paper-button[.='login']")).click();
try { Thread.sleep(3000l); } catch (Exception e) { throw new RuntimeException(e); }
if(wd.findElement(By.tagName("html")).getText().contains("please login")){
    wd.quit();
    throw new StepFailedException("Login failed");
}//End of login
System.out.println("Login was executed successfully!")
wd.quit();

As you can see, I initialized a ChromeDriver element and called it wd. Now I want to modify this script and use Katalon’s WebDriver element so I could run my test case on several browsers(Firefox,Explorer etc…) and not only Chrome.
Thank you in advance.

Roi Weinreb said:

Hello there,
I’ve created a login test for my app using Java and I also managed to run it via Katalon-Studio. This is my script:

System.out.println("\n*** Login ***\n");

//Initializing server
System.setProperty(“webdriver.chrome.driver”, “C:/selenium/chromedriver.exe”);
ChromeDriver wd = new ChromeDriver();
wd.manage().window().maximize();
wd.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);

//login
wd.get("");
wd.findElement(By.xpath("//form[@id=‘form’]/div[1]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id=‘form’]/div[1]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id=‘form’]/div[1]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("");
wd.findElement(By.xpath("//form[@id=‘form’]/div[2]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id=‘form’]/div[2]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id=‘form’]/div[2]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("");
wd.findElement(By.xpath("//form[@id=‘form’]//paper-button[.=‘login’]")).click();
try { Thread.sleep(3000l); } catch (Exception e) { throw new RuntimeException(e); }
if(wd.findElement(By.tagName(“html”)).getText().contains(“please login”)){
wd.quit();
throw new StepFailedException(“Login failed”);
}//End of login
System.out.println(“Login was executed successfully!”)
wd.quit();


As you can see, I initialized a ChromeDriver element and called it wd. Now I want to modify this script and use Katalon's WebDriver element so I could run my test case on several browsers(Firefox,Explorer etc..) and not only Chrome.  
Thank you in advance.  

  

Hello Roi,

Have you checked out Selenium Documentation on Web Driver? For example, you want to use Firefox:

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
WebDriver driver = new FirefoxDriver();
driver.get("<URL>");

Thank you for choosing Katalon Studio,
Liam