Hack Forums
[.NET] Clicking a drop down menu from web browser elements. - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Clicking a drop down menu from web browser elements. (/showthread.php?tid=5800505)



Clicking a drop down menu from web browser elements. - Moon Rock - Feb 16, 2018

So I've been stuck on this one, I've done googling and have not found a solution other then switching to ASP.net. I am trying to sign out of a website, I can see that there is a drop down menu that must be clicked before hand. This is the html element I get from Inspect element and I am unable to click it through invoke click.

Code
<button class="se-menu" aria-expanded="false" aria-label="Navigation Menu">

Clicking the above should drop down a menu where sign out is an option, but I can't even click the menu.

I have tried finding it thru the class "se-menu", this gives me a null exception, I've tried the aria-label also. Does the expanded value need to be changed also? I'm unsure how to go about this now.

I've been switching different codes to click it, but this is what I have now.



Code
Dim allelements As HtmlElementCollection = WebBrowser1.Document.All

       For Each webpageelement As HtmlElement In allelements

           If webpageelement.GetAttribute("class") = "se-menu" Then

               webpageelement.InvokeMember("click")

           End If

       Next

Huge thanks for the help 🙂


RE: Clicking a drop down menu from web browser elements. - Owl - Feb 16, 2018

See what the sign out button actually does, you might be able just to navigate to site.com/logout or something instead. If not, you should still be able to click the button regardless as it's still in the DOM.


RE: Clicking a drop down menu from web browser elements. - Moon Rock - Feb 16, 2018

(Feb 16, 2018 02:54 PM)Orka Wrote:  See what the sign out button actually does, you might be able just to navigate to site.com/logout or something instead. If not, you should still be able to click the button regardless as it's still in the DOM.

I kept trying to pull the inner text from it, and it keeps pulling blanks. I tried

Element name "button"
Attribute "class"

Returns a bunch of blanks, never sees it. Not sure how it can't see it.

I tried to pull the username attribute, it also pulls up blanks -.- I feel like this is related.


RE: Clicking a drop down menu from web browser elements. - FryPan - Feb 16, 2018

I'd suggest trying selenium out, its perfect for these types of things.


RE: Clicking a drop down menu from web browser elements. - Moon Rock - Feb 16, 2018

Just solved this, I was able to find the sign out attribute. I guess I kept mixing up the tag name with other lines or something.