import org.openqa.selenium.Point
// Define the two TestObjects to be swapped
TestObject firstObject = new TestObject("firstObject")
firstObject.addProperty("xpath", ConditionType.EQUALS, "//div[@id='firstObject']")
TestObject secondObject = new TestObject("secondObject")
secondObject.addProperty("xpath", ConditionType.EQUALS, "//div[@id='secondObject']")
// Get the locations of the TestObjects before the swap
Point firstLocationBefore = firstObject.getLocation()
Point secondLocationBefore = secondObject.getLocation()
Eventhough I import necessary package at top: import org.openqa.selenium.Point
But it's still showing underline for getLocation()
in the code.
Why it's showing underline eventhough I import necessary package in Katalon Studio?
The getLocation()
method is a member of the WebElement
class in the Selenium library. Therefore, in order to use getLocation()
, I need to create a WebElement
object and then call getLocation()
on that object. My code only have two TestObjects, so I can't use getLocation()
method.
To fix this code, I need to create a WebElement object
and then call the getLocation()
method on it:
WebElement element = DriverFactory.getWebDriver().findElement(By.xpath("//div[@id='firstObject']"));`
Point firstLocationBefore = element.getLocation();