Jump to content

How to click an Office 365 SignOut button?


Recommended Posts

I am trying to click the user's avatar then sign out. Tried many ways, all failed.

Button html:

<button class="_ho2_2 _ho2_4 ms-fwt-r ms-fcl-ns ms-bcl-nl o365button" aria-expanded="false" aria-haspopup="true" aria-label="user menu with submenu" type="button" autoid="_ho2_0"><div tabindex="-1" class="_ho2_5"><div class="_pe_12 _pe_e2"> <span class="_pe_g owaimg presenceJellyBeanBase presenceJellyBeanSmallBase presenceJellyBeanUnknownSmall _pe_i2 _pe_d2"> </span> </div><span class="_pe_h">  <div class="ms-Icon--person ms-icon-font-size-50 ms-icon-modifier-doughboy ms-bgc-nt ms-fcl-w-b ms-icon-modifier-personDoughboy ie _pe_b2"><div><img class="_pe_e _pe_b2" style="top: 0px; width: 50px; display: inline;" aria-label="Contact photo" src="service.svc/s/GetPersonaPhoto?email=user%40mailbox.com&amp;UA=0&amp;size=HR96x96&amp;sc=1487086023815"></div></div> </span></div></button>

I found the text "user menu with submenu" was the only identical string different from other buttons.

My code:

#include <IE.au3>

$sURL = "https://outlook.office365.com/owa"
Local $oIE = _IECreate($sURL)
Sleep(20000)

Local $oInputs = _IETagNameGetCollection($oIE, "button")
For $oInput In $oInputs
    If $oInput.button == "test1 menu with submenu" Then _IEAction($oInput, "click")
Nexlj212cHt.png

Link to comment
Share on other sites

Hi Subz,

Not working.

I used the following code:

$oIE = _IECreate("https://outlook.office365.com/owa", 1)
Sleep(8000)

;the following button is successfully clicked

;<button tabindex="-1" title="Write a new message (N)" class="_fce_h _fce_f ms-fwt-r ms-fcl-np o365button" aria-disabled="false" aria-expanded="false" aria-haspopup="true" aria-labelledby="_ariaId_128" type="button" autoid="_fce_1"><span class="image owaimg ms-Icon--plus ms-icon-font-size-16-circle ms-fcl-tp-b ms-bcl-tp-b ms-bg-transparent ms-icon-font-circle _fce_t"> </span><span class="label o365buttonLabel _fce_r _fce_n" id="_ariaId_128">New</span></button>

Local $oInputs = _IETagNameGetCollection($oIE, "button")
For $oInput In $oInputs
    If $oInput.title == "Write a new message (N)" Then _IEAction($oInput, "click")
Next

;the above button is ok clicked
Sleep(1000)

; the following button is not clicked

$oButtons = _IETagnameGetCollection($oIE, "button")
For $oButton in $oButtons
    If $oButton.GetElementsByTagid("aria-label") == "user menu with submenu" Then ; something wrong here
            _IEAction($oButton, "click")
        ExitLoop
    EndIf
Next

Tried " If $oButton.aria-label == "user menu with submenu" Then", complained "-" hyphen in "aria-label"

Link to comment
Share on other sites

Subz,

I tried (1) Local $oIE = _IECreate('https://outlook.office365.com/owa/logoff.owa', 1)
       or (2) _IENavigate($oIE, "https://outlook.office365.com/owa/logoff.owa")

(1)---> I have got 2 IE pages, one is still user's inbox, the other is logoff page, but I could back in the user's inbox

(2)---> I have got logoff page, clicking back button, I am in. 

 
Link to comment
Share on other sites

Can you double check the URL name, I found that on my friends account it was changing to outlook.office.com, if I use the code below it will attach without creating a new instance:

Also the https://login.microsoftonline.com/logout.srf will log out Office 365, can you try the code below and change the IEAttach url if its office365.com rather than just office.com

Local $oIE = _IEAttach('https://outlook.office.com/owa/', 'url')
_IENavigate($oIE, 'https://login.microsoftonline.com/logout.srf')

 

Link to comment
Share on other sites

Here is the running script:

#include <IE.au3>
Local $oIE = _IEAttach('https://outlook.office.com/owa/', 'url')

Sleep(8000)
_IENavigate($oIE, 'https://login.microsoftonline.com/logout.srf')

But it is hanging if using "Local $oIE = _IEAttach('https://outlook.office.com/owa/', 'url')"

Actually, after sending logoff url, clicking back once, still logoff page; clicking back twice, will back to inbox; keep clicking back button, takes me to the logon page, but if I click a the pre-configured Office 365 favorite link, I am in again.  I don't have the issue if clicking Sign Out from OWA page.

Link to comment
Share on other sites

If at the end adding "_IEQuit",  the new launched IE page will not remember the password, won't bring me to the user's Inbox. For now, just leaving the script in this way. Thanks Subz.

If anyone has any idea about how to document. get ????(aria-label) the string, please post your idea. Thans

 

Link to comment
Share on other sites

you can use GetAttribute for aria-label however this changes for example if the user is away it will have a different message, below is what I used to click the buttons, please note you may need to change url to office365.com.

#include <IE.au3>

Local $oButtons, $oIE
$oIE = _IEAttach('https://outlook.office.com/owa/', 'url')
$oButtons = _IETagNameGetCollection($oIE, "button")
For $oButton In $oButtons
    If $oButton.GetAttribute('autoid') = '_ho2_0' Then _IEAction($oButton, 'Click')
Next
$oButtons = _IETagNameGetCollection($oIE, "button")
For $oButton In $oButtons
    If $oButton.InnerText = 'Sign out' Then _IEAction($oButton, 'Click')
Next

 

Link to comment
Share on other sites

Subz, I appreciate your help, get clicked and signed out.  Didn't know how to work with _IEAttach, but switched to _IEcreate ---- worked.

Last question: Will autoid = '_ho2_0' automatically switch to somethings else? or stays " _ho2_0" forever?

#include <IE.au3>
Local $oButtons, $oIE
$oIE = _IECreate("https://outlook.office.com/owa/")
$oButtons = _IETagNameGetCollection($oIE, "button")
For $oButton In $oButtons
    If $oButton.GetAttribute('autoid') = '_ho2_0' Then _IEAction($oButton, 'Click')
Next
$oButtons = _IETagNameGetCollection($oIE, "button")
For $oButton In $oButtons
    If $oButton.InnerText = 'Sign out' Then _IEAction($oButton, 'Click')
Next

 

Link to comment
Share on other sites

I compared your code above with my friends output and it appears to be the same for her account as well.  I put a ConsoleWrite($oButton.GetAttribute('autoid') & @CRLF) within the first loop and it only showed one autoid with_ho2_0.

Also if you just use _IECreate by itself, it will always try to create a new instance of IE, I used _IEAttach so that it attached to any Window that is open with the url https://outlook.office.com/owa/.

Edited by Subz
IECreate vs IEAttach
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...