爲什麼我的代碼:硒蟒蛇被困在這條線
self.driver.find_element_by_xpath("//*[text()[contains(.,'%s')]]" % ('Sorry'))
卡住,不會通過這條線?即使我做這樣的事情:
driver.implicitly_wait(30)
self.driver.find_element_by_xpath("//*[text()[contains(.,'%s')]]" % ('Sorry'))
完整代碼:
# gets stuck here
if self.is_text_present('Hello'):
print 'Hello'
# rest of code
def is_text_present(self, text):
try:
self.driver.find_element_by_xpath('//*[contains(text(), "%s")]' % (text))
except NoSuchElementException, e:
return False
return True
您能提供您正在執行此操作的頁面源代碼嗎? – ohaal 2012-02-17 20:37:27