Javafx webview controls
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Javafx webview controls
Hi,
Our developer has implemented a username and password fields into javafx webview. I have enabled all available controls in my project properties but I am not able to get access to the fields inside webview.
Any help would be really appreciated.
Thanks
TestQA
- Labels:
-
BDD Tests
-
Desktop Testing
-
Script Tests
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This is the latest reference I can find for using Webview. See if that helps.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks Marsha. I will try and tell you if that works!
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Marsha,
I tried that link and it is very useful. However, I am facing issues setting value in the field.
When I type 'engine. ' it shows all the supported methods, but when I type 'ele. ' it doesn't show any method. So, I enter setAttributes and when I run the script it says Cannot setAttribute of null.
Any idea what's causing it?
function test() {
var engine = address.getEngine();
var ele = engine.getDocument().getElementById("username");
ele.setAttribute( "value", "abc");
}
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Usually when methods are not offered, then they aren't available for some reason, so typing them in won't work (we have all tried it that way trust me lol).
It looks like your getElementById("username") isn't working
@AlexKaras Can you help here?
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> It looks like your getElementById("username") isn't working
Agree.
> when I run the script it says Cannot setAttribute of null.
This message means that object that is expected to have setAttribute() method does not exist.
Considering the provided code sample, this means that
> var ele = engine.getDocument().getElementById("username");
engine.getDocument().getElementById("username") did not find the sought for object and thus ele variable was set to null.
P.S. Assuming that provided id was spelled correctly, it might appear to be a timing issue.
Possible code modification for quick check of this idea:
function test() {
var engine = address.getEngine();
var doc = engine.getDocument();
aqUtils.Delay(5000); // huge delay to let page be rendered
var ele = doc.getElementById("username");
if (!ele)
Log.Warning('"username" element was not found);
else
ele.setAttribute( "value", "abc");
}
/Alex [Community Champion]
____
[Community Champions] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Champions]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Champion] signature is assigned on quarterly basis and is used with permission by SmartBear Software.
https://community.smartbear.com/t5/Community-Champions/About-the-Community-Champions-Program/gpm-p/252662
================================
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks very much, I will try that. Can I also use xpath instead of id? I couldn't find GetElementbyPath() or anything like that.
update:
Tried your code and it sent 'username cannot be found'. I had a doubt that the getting element by id is not working, however I confirmed with developer and he said it was correct.
Here's the html for that particular field:
<form class="login-form">
<div class="form-group col">
<label for="username" class="xyz-test">Username</label>
<input type="text" value='' class="xyz-ctrl" id="username" placeholder="e.g. abcd" onkeyup="updateUser()" required>
<span class="invalid-fb col-4 mt-2 text-truncate">Enter username.</span>
</div>
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try to create a new project, record your actions using keyword test, then convert your keyword test to script. Have a look at the script generated, and how TC has identified the control in the name mapping.
If TC has identified the control correctly, you should then be able to copy what has been generated into your project.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @rraghvani thanks. I knew how to use keybaord shortcuts to input details but I also want to understand how webengine works.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Here's and example of using getEngine() on JavaFX WebView
