SimpleBrowserDotNet/SimpleBrowser

Question about xpath

WillForkes opened this issue · 4 comments

Is there any possible way to find an element via xpath using simple browser? I am trying to automate this form however there is absolutely no elements I can use that define the input. If you can prove me otherwise here's the link: https://twitch.tv/login
All I need is the username, password and login button. If you could help it would be very appreciated!

@wafflezzzzz Yes, you can use the following to search by XPath. After navigation to a page, the Browser.XDocument property holds an XML interpretation of the parsed HTML. If SimpleBrowser had a user interface, it's the XDocument that would be rendered. There's nothing special about the XDocument, or more specifically System.Xml.Linq.XDocument. Call the XDocument.XPathSelectElement method to perform an XPath search.

XPath, however, isn't your problem when it comes to twitch.tv/login. Looking at the source downloaded, there isn't a login form on the page at all. You may see one in Chrome, but the login form is rendered using JavaScript. Since SimpleBrowser doesn't have a JavaScript engine, it doesn't create a login form. The login form will never get created in the XDocument to be found by XPath.

@wafflezzzzz Yes, you can use the following to search by XPath. After navigation to a page, the Browser.XDocument property holds an XML interpretation of the parsed HTML. If SimpleBrowser had a user interface, it's the XDocument that would be rendered. There's nothing special about the XDocument, or more specifically System.Xml.Linq.XDocument. Call the XDocument.XPathSelectElement method to perform an XPath search.

XPath, however, isn't your problem when it comes to twitch.tv/login. Looking at the source downloaded, there isn't a login form on the page at all. You may see one in Chrome, but the login form is rendered using JavaScript. Since SimpleBrowser doesn't have a JavaScript engine, it doesn't create a login form. The login form will never get created in the XDocument to be found by XPath.

Thanks for the detailed reply! I will definitely give your method a shot on a different page and feedback the results.

@wafflezzzzz How is it going? Any luck?

I haven't received a response in a week. Therefore, I'm closing this issue. It can be reopened later, if needed.