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.
I finally found it :
Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('test');
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.
I finally found it :
Sys.Browser().Page('*').QuerySelector('[data-bind="value: sMatricule"]').SetText('test');
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,
Up... any help please ? Thank you !
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.
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.
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 :
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.
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.
@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!
Subject | Author | Latest Post |
---|---|---|