我想单击Facebook上每个成员的个人资料,但是在循环播放时出现错误。
这是我的代码:
def open(link):
try:
driver.get(link)
except:
print('no internet access')
def OpenProfileMember():
open('https://mbasic.facebook.com/browse/group/members/?id=1600319190185424')
find = driver.find_elements_by_class_name('bn')
for x in find:
if x != find[0]:
x.click()
time.sleep(3)
driver.back()
else:
continue
OpenProfileMember()
这是我收到的错误消息:
PS C:\Users\LENOVO> & C:/Python27/python.exe "c:/Users/LENOVO/OneDrive/Documents/project/python/Selenium/robot olshop.py" Traceback (most recent call last): File "c:/Users/LENOVO/OneDrive/Documents/project/python/Selenium/robot olshop.py",line 77,in <module>
OpenProfileMember() File "c:/Users/LENOVO/OneDrive/Documents/project/python/Selenium/robot olshop.py",line 70,in OpenProfileMember
x.click() File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py",line 80,in click
self._execute(Command.CLICK_ELEMENT) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webelement.py",line 633,in _execute
return self._parent.execute(command,params) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\webdriver.py",line 321,in execute
self.error_handler.check_response(response) File "C:\Python27\lib\site-packages\selenium\webdriver\remote\errorhandler.py",line 242,in check_response
raise exception_class(message,screen,stacktrace) selenium.common.exceptions.StaleElementReferenceException: Message: The element reference of <a class="bn" href="/rxrzimam?fref=gm"> is stale; either the element is no longer attached to the DOM,it is not in the current frame context,or the document has been refreshed