任何人都可以指出我实施的内容有什么问题如下:
def setUp(self):
self.driver = selenium.webdriver.Chrome()
self.page = self.driver.get("http://mywebsite/form")
self.page.search_trip(2, 2)
def search_trip(self, depart, arrival):
departing = Element(Locators.XPATH, "//select[@name='departing']/option[@value='%i']" %depart)
returning = Element(Locators.XPATH, "//select[@name='returning']/option[@value='%i']" %arrival)
search = Element(Locators.XPATH, "//input[@type='submit']")
self.departing.click()
self.returning.click()
self.search.submit()
错误代码:
self.page.search_trip(2, 2)
AttributeError: 'NoneType' object has no attribute 'search_trip'
答案 0 :(得分:0)
drive.get(url)
不返回任何内容!和search_trip
是一个属于类的方法,而不是self.page对象(这里没有)!
def setUp(self):
self.driver = selenium.webdriver.Chrome()
#driver.get() returns None
self.driver.get("http://mywebsite/form")
#search_trip is a method inside the class.
self.search_trip(2, 2)
def search_trip(self, depart, arrival):
departing = Element(Locators.XPATH, "//select[@name='departing']/option[@value='%i']" %depart)
returning = Element(Locators.XPATH, "//select[@name='returning']/option[@value='%i']" %arrival)
search = Element(Locators.XPATH, "//input[@type='submit']")
self.departing.click()
self.returning.click()
self.search.submit()