QuerySelector
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
QuerySelector
Hi,
I'm new to this feature, I would like to identify an object to use the "SetText()" or "Key()" method on it.
Could Someone tell me what should I write in CSSSelector to identify this object ?
(The identifier is "sMatricule")
Thank you !
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I finally found it :
Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('test');
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I don't understand something :
I write my script with the following code :
Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('00052');
And when I close the browser, re-open it I try to replay the script it says "Undeclared identifier: SetText".
Anyone has an idea ?
Thanks,
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Up... any help please ? Thank you !
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
> "Undeclared identifier: SetText"
This means that the sought for object (.QuerySelector('[data-bind="value: sMatricule"]')) was not found, .QuerySelector() returned null and thus runtime engine failed to reference the SetText identifier.
/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
What browser are you using?
One thing I've noticed is that when you close a browser in windows, sometimes there's an instance of the browser that hangs out in memory. I've seen this with Chrome and IE. So, your code is very non-specific. You're not specifying a particular browser or browser instance. Nor are you designated a specific page. So, when you close down and re-open and try and run again, if there is any residual memory instance of a web browser, you could very well be finding absolutely nothing.
You should get in the habit of specifying better details in the code to indicate both browser and page you're operating against. I've also made it a point in any web automation I do that, when starting up a test, I scan the processes in memory for any browser instances, kill them, and then re-launch the browser via code and make sure that browser instance is what I'm using in my code.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hey Robert, thanks for helping !
I'm using ie.
I may precise a little bit more my problem :
When I play the whole sequence (I mean, go to the desired webpage and act on edit components with QuerySelector) it goes well to the page and then gives me this error message.
But when I'm on the web page, and if I execute the line alone, it works !
I don't catch the difference...
Here is what I execute from the menu :
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Why aren't you using Aliases.browser.pageXXXXX.QuerySelector?
The reason I ask is that ie sometimes opens multiple instances in Windows... and so there may be blank pages and such out there that are in different indexed instances of IE.
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
a) Robert is correct with his note. Any reason not to use Aliases.browser.page ?
b) Exactly as I said (without knowing your tested application details) - button click reloads the page, but your code does not wait for page to load and looks for the object. As the object does not exist yet, the search fails.
At least, I would recommend to execute
Aliases.browser.page.Wait()
after the click to wait for the page to load. Depending on your tested application, additional delays might be required to wait for page scripts and relevant Ajax calls to complete.
/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
@AlexKaras wrote
b) Exactly as I said (without knowing your tested application details) - button click reloads the page, but your code does not wait for page to load and looks for the object. As the object does not exist yet, the search fails. At least, I would recommend to execute Aliases.browser.page.Wait() after the click to wait for the page to load. Depending on your tested application, additional delays might be required to wait for page scripts and relevant Ajax calls to complete.I didn't even catch that. Yeah, that would be EXACTLY why it only works if you run just the line. Good catch!
Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----
Why automate? I do automated testing because there's only so much a human being can do and remain healthy. Sleep is a requirement. So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.
Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
