SeldomQA / poium

Page Objects design pattern test library, support selenium、appium、playwright, etc
https://pypi.org/project/poium
Apache License 2.0
404 stars 138 forks source link

单个元素的定位,返回类型是poium Element,导致调selenium的drag_and_drop 报错move_to requires a WebElement #35

Open herbyhabi opened 2 years ago

herbyhabi commented 2 years ago

node_combiner_loc = Element(xpath='xxxx') connect_point_list_loc = Elements(xpath='xxxxxx')

def drag_el1_to_el2(self): self.node_start_loc.click() print(self.connect_point_list_loc) # 元素list print(self.node_combiner_loc) # 单个元素 ActionChains(self.driver).drag_and_drop(self.connect_point_list_loc[0], self.node_combiner_loc).perform()

执行时提示: AttributeError: move_to requires a WebElement

打印出来的元素类型: connect_point_list_loc: [<selenium.webdriver.remote.webelement.WebElement (session="1cea47d0fadcbda3a11877b5c3d228bd", element="4f22683b-e2ee-4f42-9f7b-235e4b013598")>]

node_combiner <poium.page_objects.Element object at 0x7ff003f36a10>

想问下,这种情况要怎么解决?

defnngj commented 2 years ago

drag_and_drop() 要的元素是 WebElement 类对象。 poium 返回的 是 Element 类对象。 所以 无解。 你只能 写 selenium 的定位。

node_combiner_loc = driver.find_element_by_xpath('xxxx')
connect_point_list_loc = driver.find_elements_by_xpath('xxxxxx')