1

I'm having trouble finding elements by xpath or id inside of outlook's online html. I'm using selenium and python. Here is what I've wrote.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.common.exceptions import NoSuchElementException #imports

browser = webdriver.Chrome('C:\\Users\\...')
browser.get('https://www.office.com/...') #setup

#then some code to sign into outlook online

browser.find_element_by_xpath('//*[@id="_ariaId_64"]/div/div/div[1]')

browser.find_element_by_xpath('//*[@id="MailFolderPane.FavoritesFolders"]/div[19]')

browser.find_element_by_id('_ariaId_68') #attempts to find an element in outlook

this is the element I'm trying to access. I would post the entire html, but there is just so much. I'm brand new to all things code so go easy on me :)

<div>
   <div id="_ariaId_68" aria-expanded="false" draggable="true" dropzone="string:text/plain">
      <div autoid="_n_R" class="_n_44 canShowFavoritesAction" role="treeitem" aria-expanded="false" aria-labelledby="_ariaId_68.folder _ariaId_68.ucount" aria-haspopup="true" tabindex="-1">
         <div class="_n_S3 nowrap border-color-transparent _n_X3" style="padding-left: 4px;">
            <div class="_n_V3 _n_54">
               <span autoid="_n_S" class="_n_W3 ms-font-m ms-fwt-sl _n_Y3" id="_ariaId_68.folder" title="Sent Items">Sent Items</span>  
               <div class="_n_24 ms-bg-color-neutralLighter"> <span autoid="_n_T" class="ms-font-m _n_Z3 ms-fwt-sb ms-fcl-tp" aria-hidden="true"></span> </div>
               <span class="ms-font-s ms-fcl-ns" aria-hidden="true" aria-expanded="false" aria-haspopup="true" tabindex="-1">  </span>   <button autoid="_n_U" type="button" class="_n_34 ms-fwt-r ms-fcl-ns o365button hidden" style="display: none;" tabindex="-1"></button>  <span style="display: none;" aria-hidden="true"></span> 
            </div>
            <div class="_n_14 hidden"><button autoid="_n_V" type="button" class="_n_04 firefoxFavorite o365button" title="Remove from Favorites" aria-labelledby="_ariaId_69"><span class="_fc_3 owaimg ms-Icon--star ms-icon-font-size-18 ms-fcl-ns-b"> </span><span class="_fc_4 o365buttonLabel _fc_2" id="_ariaId_69" style="display: none;"></span></button></div>
         </div>
      </div>
   </div>
</div>
Lucas Wieloch
  • 818
  • 7
  • 19
rindlism
  • 11
  • 4
  • The subtance of your post is not bad, but could you please format it better? For example organize it better instead of a bunch of random headers and format the code so that is not basic text. Take a look here for help https://stackoverflow.com/help/formatting – B. Cratty Oct 25 '18 at 18:14
  • 1
    Thanks for that suggestion, B. Cratty. Also thanks for editing, Lucas Wieloch. Much appreciated. – rindlism Oct 25 '18 at 18:29

1 Answers1

0

Assuming you're trying to find the SENT ITEMS's - web element.

The SENT ITEM link does not seem to be the visible area [when you have more sub folders inside Inbox, this usually happens] and hence you first make a scroll to view to the element before performing anything on the element.

Here are the options to bring the element to visible area

Try with following xpath //span[@title='Sent Items']

Dhamo
  • 1,171
  • 3
  • 19
  • 41
  • Okay, I tried the sent items path. It still didn't work. I think I need to do some research on finding iframes. I know there are a lot in the html, and I may be trying to work with code that is inside of one. Its just that my elemeny inspector won't show any iframes unless I search for them in the search bar, and then it is impossible to navigate back to the original path. Its just a really large confusing code, so I need to figure out what the real path is somehow. – rindlism Oct 28 '18 at 17:13