I had created a new WebDriver object,
WebDriver driver=new ChromeDriver()
however it would open a new browser session and I am not able to manipulate the created driver object to my needs.
I have a scenario to use the Action class, which passes the driver as a parameter
Actions builder = new Actions(driver)
Even for other scenarios it is simpler if I could use the driver object.
Please let me know if I can integrate this with the current browser session launched by katalon.
Thanks.
If your question is the title, then I think you should add this line at the begining of your script :
import org.openqa.selenium.WebDriver as WebDriver
To use the current session created by Katalon Studio, you can refer to example code below:
WebDriver driver = DriverFactory.getWebDriver()
The returned ‘driver’ parameter will use the current browser’s session launched by Katalon Studio. You need to import necessary libraries also (can be done by pressing Ctrl + Shift + O)
1 Like
Thanks a lot Vinh, really appreciate your prompt response. That was what i was looking for all this time, can’t wait to try.
Hi! I am using the same code:
WebDriver driver = DriverFactory.getWebDriver()
But is not working for me.
Help!
Almudena said:
Hi! I am using the same code:
WebDriver driver = DriverFactory.getWebDriver()
But is not working for me.
Help!
You need to have your browser opened first using ‘Open Browser’ keyword so that you can use this DriverFactory.getWebDriver()
Vinh Nguyen said:
Almudena said:
Hi! I am using the same code:
WebDriver driver = DriverFactory.getWebDriver()
But is not working for me.
Help!
You need to have your browser opened first using ‘Open Browser’ keyword so that you can use this DriverFactory.getWebDriver()
Hello, i try to use this approach but was not working.
I’m opening browser in another TC (login) after that, i’m calling yet another TC. After that i’m trying to count no. of results in search.
When i use xpath in browser it can find elements correctly, however, it finds 0 when executed from Katalon
WebDriver driver = DriverFactory.getWebDriver()
searchCount = driver.findElements(By.xpath(’//div[@data-caseid]’)).size()
any ideas?
Andrej Podhajský said:
Vinh Nguyen said:
Almudena said:
Hi! I am using the same code:
WebDriver driver = DriverFactory.getWebDriver()
But is not working for me.
Help!
You need to have your browser opened first using ‘Open Browser’ keyword so that you can use this DriverFactory.getWebDriver()
Hello, i try to use this approach but was not working.
I’m opening browser in another TC (login) after that, i’m calling yet another TC. After that i’m trying to count no. of results in search.
When i use xpath in browser it can find elements correctly, however, it finds 0 when executed from Katalon
WebDriver driver = DriverFactory.getWebDriver()
searchCount = driver.findElements(By.xpath(’//div[@data-caseid]’)).size()
any ideas?
just did a test - when i use on beginning of TC WebUI.navigateToUrl (even page was already opened in previously called TC) i got correct result