I want to create a .NET app which helps me to manage and automate a web browser. I did a quick search, and I found some solutions.
It seems that Selenium is the main reference software (open source), but it does not allow interaction between the Windows Form and the browser.
If I understand correctly, based on the source code of Selenium, have been built others software that allow to do so. In particular I've read about Winium, Watin, White and Sikuli.
At this page I've found a short comparison of some of them
https://blog.testproject.io/2016/12/22/open-source-test-automation-tools-for-desktop-applications/
I would like some advice on which one to use.
I'm an amateur programmer in VB.NET, but I've no problem in translating from C#.
I would like to use Chrome, but regarding Watin I read that it does not support Chrome, and it supports old version of other browser (Internet Explorer 9, and Firefox 2.x). Do you know if this actually create problems in loading pages?
I also need a software that can handle the delay while loading pages.
In example, with .NET WebBrowser class, I use the instruction:
Do Until wb.ReadyState = WebBrowserReadyState.Complete
Or previously I mix WebBrowser class with HtmlAgilityPack, in this mode:
Do
Application.DoEvents()
' we create a delay, that allow the page to be loaded correctly:
' Thread.Sleep(...) Don't allow the page load correctly
Dim delay as Date = Date.Now.AddMilliseconds(1000)
Do While delay > Date.Now
Loop
documentAsIHtmlDocument3 = DirectCast(wb.Document.DomDocument, mshtml.IHTMLDocument3)
sr = New StringReader(documentAsIHtmlDocument3.documentElement.outerHTML)
docPreview.Load(sr)
nodeTmp1 = docPreview.DocumentNode.SelectSingleNode("//div[@id='content']")
nodeModule = nodeTmp1.SelectNodes("descendant:: div[@class='module']")
Loop Until IsNothing(nodeModule) = False
But I don't like this type of solution for lots of reasons, and reading the code, I think you could imagine why.
Do you have advices?
10/01/2018 Update: i've found a similar thread:
View Generated Source (After AJAX/JavaScript) in C#
Where users confirm they feel good using of Selenium and Watin. They rise an issue about slow performance. Others suggestions?
_________ in reply to Rescis _________
This is a piece of code i made with Watin
Imports WatiN.Core
...
Private browser As New IE
...
browser.GoTo("https://www.the_site_with-wich_i_have_my_account/")
...
Private Sub joinAccount()
'Usually a website it's built with an HTML 'container' that contains Username and Password textBox and a Join button:
'With chrome right click on that element, and 'inspect element' we can analize the HTML code and we can find the name of the class of the container
Dim formLogin As WatiN.Core.Form = browser.Form(Find.ByClass("class_found_from_chrome_inspect_element"))
'search for Username textBox
Dim tbUsername As WatiN.Core.TextField = formLogin.TextField(Find.ById("Username_textField_found_from_chrome_inspect_element"))
'set our username
tbUsername.SetAttributeValue("value", "my_username")
'search for Password textBox
Dim tbPassword As WatiN.Core.TextField = formLogin.TextField(Find.ById("Password_textField_found_from_chrome_inspect_element"))
'set the password
tbPassword.SetAttributeValue("value", "my_password")
'search the Join button and perform click
formLogin.Button(Find.ById("Join_button_found_from_chrome_inspect_element")).Click()
End Sub