Focus verification

When I load my web page the mouse cursor should display in 1st column of the 1st grid of page.So I have to verify that mouse cursor is coming or not…
How can I verify the by default focus is coming on expected field or not ?
please help me with that…!!

Yogesh Dhami said:

When I load my web page the mouse cursor should display in 1st column of the 1st grid of page.So I have to verify that mouse cursor is coming or not…
How can I verify the by default focus is coming on expected field or not ?
please help me with that…!!

me too!!!

Try the following test case:

import static com.kms.katalon.core.testobject.ConditionType.EQUALS
import org.openqa.selenium.WebDriver
import org.openqa.selenium.WebElement
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.driver.DriverFactory
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
TestObject tObj = new TestObject()
WebUI.openBrowser('')
WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
tObj.addProperty('xpath', EQUALS, "//a[@id = 'btn-make-appointment']")
WebUI.click(tObj)
tObj.addProperty('xpath', EQUALS, "//input[@id = 'txt-username']")
WebUI.verifyElementPresent(tObj, 10)
WebDriver driver = DriverFactory.getWebDriver()
// find which element is currently focused by cursor
WebElement focusedElement = driver.switchTo().activeElement()
if (focusedElement.getTagName() == 'input') {
WebUI.comment(">>> SUCCESS focused element is ${focusedElement.getTagName()}")
} else {
WebUI.comment(">>> FAILED focused element is ${focusedElement.getTagName()}")
}
WebUI.setText(tObj, 'John Doe')
WebUI.delay(3)

see also:

4 Likes