当我运行下面的代码时,出现错误“ TypeError:'ActionChains'对象不可迭代”。我在做什么错了?
回溯(最近通话最近):文件 “ /Users/Albert/Automation/online-tests/drawingTest.py”,第55行,在 test_onlineTest self.test_drawGreenPencil()文件“ /Users/Albert/Automation/online-tests/drawingTest.py”,第147行,在 test_drawGreenPencil self.draw_lines(action,[(60,-30),(40,30),(-40,30),(-60,-30)])文件“ / Users / Albert / Automation / online-tests / drawingTest .py“,第59行,在draw_lines中 对于偏移量中的o:TypeError:“ ActionChains”对象不可迭代
这是代码段:
driver.find_elements_by_css_selector('.tRight.altRow')
答案 0 :(得分:0)
您已经执行了该操作。请重新创建它。
def draw_lines(self, offsets, scale=1):
for o in offsets:
action = ActionChains(self.driver)
action.click_and_hold()
action.move_by_offset(scale * o[0], scale * o[1])
action.release().perform()
def test_drawGreenPencil(self):
...
self.draw_lines(self, [(-30, 60), (30, 40), (30, -40), (-30, -60)])