Annet
Annet

Reputation: 673

Page-object method to get an element location

I need to get an element coordinates(location) using cooresponding page-object method. Now I'm using the following method to get it:

- myelementname_element.wd.location[0] --> to get X
- myelementname_element.wd.location[1] --> to get Y

But I'm constantly getting the following warning:

DEPRECATION WARNING

  • You are calling a method named wd at d:/JenkinsWorkspace/jenkins/...
  • This method does not exist in page-object so it is being passed to the driver.
  • This feature will be removed in the near future.
  • Please change your code to call the correct page-object method.

Could you please help me and provide me with corresponding page-object method?

TIA, ANNA

Upvotes: 1

Views: 1039

Answers (1)

Justin Ko
Justin Ko

Reputation: 46846

To use methods supported by watir-webdriver (or selenium-webdriver) elements, but not directly supported by the page-object-gem elements, you need to first get the native element. This is done by calling the element method for the page-object-gem element:

myelementname_element.element

As you can see, you can get the three different gem element classes by doing:

puts page.myelementname_element.class
#=> PageObject::Elements::TextField

puts page.myelementname_element.element.class
#=> Watir::TextField

puts page.myelementname_element.element.wd.class
#=> Selenium::WebDriver::Element

For your specific example, you want to do:

myelementname_element.element.wd.location[0]
myelementname_element.element.wd.location[1]

Upvotes: 2

Related Questions