DriverFactory.getWebDriver() use-cases?

What is the significance of the code-
Webdriver driver=pagefactory.getwebdriver()

And in which scenario/situation do we use this code?

Where did you find this code?

What is PageFactory?

UPDATE: The method doesn’t seem to exist per official documentation

Apologies! My Bad!!

Correct code is -

WebDriver driver=driverfactory.getWebDriver()

Ok, so what happens when you search the Katalon documentation for DriverFactory ?

The simple answer is that you are creating a variable (or an alias) called, driver, (of the data type, WebDriver) rather than retype “DriverFactory.getWebDriver()” all the time. Note the capital D for Driver and the capital F for Factory in DriverFactory as Java/Groovy is case-dependent (meaning a capital letter is not the same as a lower-case letter). Also note the parameters after the “getWebDriver”–this indicates that the reference is for a method. So every time you call the long form, the method has to run to determine the proper WebDriver that is needed. Once you run this once and create the variable, like I show below, now I have the proper WebDriver and can use it.

"start of test1 part5"

WebDriver driver = DriverFactory.getWebDriver();
"pause to ensure table is formed"
WebUI.waitForElementVisible(findTestObject('myPage/td_TableAreaLine'), 10)
'To locate table'
Table = driver.findElement(By.xpath("//table/tbody"));   <== we can use the DriverFactory.getWebDriver() form here as well

For the longer answer, as @mwarren04011990 suggests, there will be loads of information on what it does.

2 Likes