我使用Office 365导航栏尝试单击用户图标以输入另一个邮箱,但是硒无法通过id,class_name或xpath识别它吗?
elem6 = driver.find_element_by_xpath('//*[@id="O365_MeFlexPane_ButtonID"]')
elem6.send_keys(Keys.RETURN)
html标记
<button type="button" class="o365cs-nav-item o365cs-nav-button o365button ms-bgc-nlr ms-fcl-b o365cs-spo-topbarMenuOpen" role="menuitem" title="Carlos Loayza Cuestas" id="O365_MeFlexPane_ButtonID" aria-disabled="false" aria-label="Use la flecha hacia abajo para utilizar el panel Mi cuenta para ver y editar su cuenta y cerrar la sesión"><div class="o365cs-mfp-header"> <div class="o365cs-mfp-header-displayname o365cs-rsp-tn-hide o365cs-mfp-header-displayname-wrap o365cs-display-none"> <span class="" role="presentation">Carlos Loayza Cuestas</span> </div> <div class="o365cs-nav-button o365cs-mfp-header-img"> <div class="o365cs-mfp-doughboy-container"> <span class="ms-bgc-nt ms-fcl-w o365cs-mfp-doughboy o365cs-mfp-circular-small owaimg ms-Icon ms-Icon--Contact ms-icon-font-size-52" aria-hidden="true"> </span> </div> <div class="o365cs-mfp-textboy o365cs-mfp-circular-small" style=""><div class="" style=""><div style="background-color: rgb(118, 118, 118); outline-color: rgb(118, 118, 118);">CC</div></div></div> <div style="display: none;"></div> <div class="o365cs-mfp-header-img-container o365cs-mfp-circular-small" style="display: none;"><img aria-hidden="true" src="service.svc/s/GetPersonaPhoto?email=carlos.loayza@telefonica.com&UA=0&size=HR64x64&sc=1559170428032"></div> <div autoid="__Microsoft_O365_ShellG2_MeFlexHeaderButton_Owa_templates_cs_0" class="o365cs-mfp-presenceButton ms-Icon--skypeCheck o365cs-mfp-skypeAvailable"></div> </div> </div><div class="o365cs-flexPane-unseenitems"> <span class="o365cs-flexPane-unseenCount ms-fcl-w ms-bgc-tdr" style="display: none;"></span> <span class="o365cs-flexPane-unseenCount owaimg ms-Icon--starburst ms-icon-font-size-12 ms-fcl-w ms-bgc-tdr" style="display: none;"> </span> </div></button>
python给我以下结果
Traceback (most recent call last):
File "C:\Users\wcondorp\Videos\Selenium\prueba.py", line 80, in <module>
elem6 = driver.find_element_by_xpath('//*[@id="O365_MeFlexPane_ButtonID"]') #mail, onedrive, calendaria
File "C:\Users\wcondorp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 394, in find_element_by_xpath
return self.find_element(by=By.XPATH, value=xpath)
File "C:\Users\wcondorp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 978, in find_element
'value': value})['value']
File "C:\Users\wcondorp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 321, in execute
self.error_handler.check_response(response)
File "C:\Users\wcondorp\AppData\Local\Programs\Python\Python37-32\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="O365_MeFlexPane_ButtonID"]"}
(Session info: chrome=74.0.3729.169)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}),platform=Windows NT 10.0.17134 x86_64)