Does anyone have any information about automating interactions with websites using WebView?
I would like to log in to a web site automatically, to push buttons under program control, etc.
Also how does WebView handle cookies?
Automation with WebView
- ninalanyon
- Posts: 4
- Joined: Tuesday 13th August 2024 9:28pm
- Location: Norway
- BruceSteers
- Posts: 1831
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Automation with WebView
It all depends on the webpage you are trying to automate.
Usually it's done using JavaScript
WebView.ExecJavascript() method.
Usually it's done using JavaScript
WebView.ExecJavascript() method.
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- ninalanyon
- Posts: 4
- Joined: Tuesday 13th August 2024 9:28pm
- Location: Norway
Re: Automation with WebView
I'm playing with the Corlomo CBrowser example project. The Webview control doesn't have an ExecJavascript method.
This page says it does have it: https://gambaswiki.org/wiki/comp/gb.qt5.webview/webview
Any idea what have I done wrong?
This page says it does have it: https://gambaswiki.org/wiki/comp/gb.qt5.webview/webview
Any idea what have I done wrong?
- BruceSteers
- Posts: 1831
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Automation with WebView
No idea at all. I cannot see your code
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- ninalanyon
- Posts: 4
- Joined: Tuesday 13th August 2024 9:28pm
- Location: Norway
Re: Automation with WebView
The code is just
When it is called I get this output
Sub x()
Try WebView1.ExecJavascript("abc")
Print Error.Code
Print Error.Text
End
When it is called I get this output
11
Unknown symbol 'ExecJavascript' in class 'WebView'
- BruceSteers
- Posts: 1831
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Automation with WebView
it works fine here.
My guess would be that you are not using gb.gui.webview but using the old gb.qt.webkit
gb.qt.webkit (that was QT only) is now depreciated so you should use gb.gui.webview (QT and GTK) instead
https://gambaswiki.org/wiki/comp-deprecated : do not use these ones
https://gambaswiki.org/wiki/comp : use these.
Ps. your code could be showing an old error (Error.code and Error.text may be filled from a previous error not the last Try)
You should do it like this...
I get this result..
-1
Javascript error: undefined:1:4: ReferenceError: Can't find variable: abc
And that's correct as "abc" is invalid javascript
My guess would be that you are not using gb.gui.webview but using the old gb.qt.webkit
gb.qt.webkit (that was QT only) is now depreciated so you should use gb.gui.webview (QT and GTK) instead
https://gambaswiki.org/wiki/comp-deprecated : do not use these ones
https://gambaswiki.org/wiki/comp : use these.
Ps. your code could be showing an old error (Error.code and Error.text may be filled from a previous error not the last Try)
You should do it like this...
Sub x()
Try WebView1.ExecJavascript("abc")
If Error Then
Print Error.Code
Print Error.Text
Endif
End
I get this result..
-1
Javascript error: undefined:1:4: ReferenceError: Can't find variable: abc
And that's correct as "abc" is invalid javascript
If at first you don't succeed , try doing something differently.
BruceS
BruceS
- ninalanyon
- Posts: 4
- Joined: Tuesday 13th August 2024 9:28pm
- Location: Norway
Re: Automation with WebView
Perfect Now I get the error you expected. And i understand a bit more about how Gambas works.
Thank you very much.
Thank you very much.
Re: Automation with WebView
By using QT6, I obtain in console:
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/bin/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
js: Uncaught ReferenceError: abc is not defined
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/bin/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
js: Uncaught ReferenceError: abc is not defined
Europaeus sum !
Amare memorentes atque deflentes ad mortem silenter labimur.
Amare memorentes atque deflentes ad mortem silenter labimur.
- BruceSteers
- Posts: 1831
- Joined: Thursday 23rd July 2020 5:20pm
- Location: Isle of Wight
- Contact:
Re: Automation with WebView
ooh your qt6 doesn't seem too happy. looks like spell checker config issue.vuott wrote: ↑Friday 16th August 2024 1:23am By using QT6, I obtain in console:
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/bin/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
Path override failed for key base::DIR_APP_DICTIONARIES and path '/usr/lib/qt6/qtwebengine_dictionaries'
js: Uncaught ReferenceError: abc is not defined
If at first you don't succeed , try doing something differently.
BruceS
BruceS
Re: Automation with WebView
Hi BruceSteers,
...evidently my QT6 has not yet learnt that life can be bitter !
Europaeus sum !
Amare memorentes atque deflentes ad mortem silenter labimur.
Amare memorentes atque deflentes ad mortem silenter labimur.