We can use to() function to open url, to() function opens a web page in the browser window, It allows to a pass a String parameter or URL Type parameter, and its return type is a void.
driver.navigate().to("https://google.com)
The title property is used to retrieve the title of the webpage the user is currently working on. A null string is returned if the webpage has no title.
We can compare the string using '==' operator
if(driver.title == "Google"){
println("matching")
}
else{
println("not matching")
}
The currentUrl property is used to retrieve the URL of the webpage the user is currently opened.
driver.currentUrl
close() function closes the web browser window that the user is currently working on or we can also say the window that is being currently accessed by the kotlin selenium. close() function does not accept any parameter and returns nothing (yes, return type of nothing).
fun main(args: Array) {
val driver = FirefoxDriver()
driver.get("https://chercher.tech")
driver.close()
}
import org.openqa.selenium.firefox.FirefoxDriver
fun main(args: Array<String>) {
// Set geckodriver path
System.setProperty("webdriver.gecko.driver", "C:\\PATH\\geckodriver.exe")
// Open browser
val driver = FirefoxDriver()
// open google
driver.get("https://google.com")
}
Article is written by Pavan (a) KarthiQ. Well, I am serving notice period in an MNC, Bangalore. I thought to enrich every person knowledge a little, I always have a feeling, when we teach something, we will learn more than what you know.
Knowledge is the only thing that doubles when you spend it.
I have also created the reporter for Protractor Jasmine. Use for your projects without any hesitation