“type | id=ABC | Test Role”
selenium.type(“id=ABC”, “Test Role”)
This works fine. But of course it is not a standard Java or WebUI commands of which you have spoken.
Right. And since my selenium experience is limited (to a few brief months 2 million years ago when Se first came out and now, recently, playing with Katalon Recorder as a “refresher”) that’s the kind of thing I meant by I’m not the best person to advise, perhaps. That said, …
If it works for you, great.
Let’s say your team adds a section to your company’s product website
with 5 new pages with a total of 100 new fields. Each such field has a
unique CSS/XPATH. Assume you did not participate in writing the new
code. YOU must now write auto-tests of these five pages and 100
fields. You must now find and record 100 different CSS/XPATH strings!!!
Right. One way or another, “something” (someone) needs to tell the system (webdriver) what to click on, what to examine, what to hover over, etc. Broadly speaking, you have two choices:
1 - The “easy” route, using a tool like “Spy Web” (and live with the mountain of TestObjects in the Object Repository)
2 - The “by-hand” route and not have a maintenance headache managing the OR.
The thing I like best about #2 is this: when I search for items in my test code, the detail is right there staring me in the face -- it’s not buried in another place (the OR) which I need to move to, browse, find the damn thing and open it, then realize I opened the wrong thing because two (or more) things right next to each other are similarly named or because Spy Web created multiple “page” objects with multiple test objects almost (or completely) identical… and and and…
Get the picture?
Sorry. I don’t have time for that. Analogy: there’s a reason you don’t keep individual socks in individual sock drawers. That would be crazy, right?
My mental picture of you is opening Firepath/Firebug in Mozilla Firefax,
scouring the page for each individual CSS/XPATH, copying and pasting
each one into a simple .txt file which eventually has 100 lines, and
then copying and pasting the CSS/XPATHs from the .txt file to Katalon as
needed.
Mozilla Firefax That’s great
Well, that’s close but let me detail it for you:
First, I have a copy of Firefox Nightly running on my desktop, open to the page I’m currently running tests against. No Firepath/Firebug, I use the native FF devtools (hit F12 to see them).
Here’s my method:
1 - In FF, right-click on the element of interest (a text box for example).
- The context menu appears.
2 - Click on “Inspect Element”
- the devtools inspector opens and highlights the item of interest. If not, it’s pretty close.
- I always have my devtools separated from the main browser window (on a separate monitor). But that’s just me…
3 - If the item has an ID, I double-click the ID value, (puts you in edit mode) and hit Ctrl-C (copy)
Now I have the thing I want I can use it in my test in KS.
Obviously, sometimes I need to figure out a bit more CSS than just an ID, especially if the element doesn’t have an ID but that’s beyond the scope of this writeup… you just gotta learn it
What you could do is use the Spy tool to let it figure out the CSS/xpath for you, then copy that into your code and delete the Test Object from the OR (since, as we’ve agreed, we don’t need it). Plus, doing it that way, you’ll get to learn how you can yourself construct better CSS/xpath as you go… make sense?
Okay… I hope that helped.
And by the way, don’t think of it as “hundreds of CSS strings” you need to copy/paste. The aim here is that every single test (and test step) you write should be robust and rock-solid. When things “go wrong” (and they will!) you only have one place to look. Plus, without TOs to worry about, copying/renaming TestCase code between projects becomes very easy. Almost too easy.
Let me know if any of that wasn’t clear.
Russ
p.s. Today, I’ve almost reduced my OR to nothing.