Recognize elements on a new page

Hello, when automation opens a different page but with the same flow, the elements of this new page are not recognizing me, what can I do?

We will need much much more information:

Automation starts well, passes 14 steps correctly, but upon reaching step 15, which consists of identifying a magnifying glass to select the value of a text cap found in a new window, automation stops and error comes out. This new window opens when step 14 is executed correctly. Attached screenshot of the steps and the error.

@acuadros For a test, after the “maximizeWindow()” statement, put in a LONG delay, like delay(10). If the image is clicked, then your concern is a timing issue and you can play with a smaller “delay” or, even better, insert one of the “wait” statements, like waitForElementClickable().

Done, I will apply those recommendations, but the error is that it does not recognize the field after opening another window other than the initial one.

@acuadros Is there any text on the new page that you can verify, verifyTextPresent(“text”, false)?

I also see the “java.lang.IllegalArgumentException” message. Maybe @Brandon_Hein can help you with that?

A couple of things:

1.) If you don’t want to deal with maximizing the window every time in the script, it’s much easier to handle it with a desired capability:

Open Project > Settings > Desired Capabilities > WebUI > Chrome, click the Add button, and set:

  • Name = args
  • Type = List
  • Value = start-maximized

2.) I’ve never used the clickImage() method, so not sure how it differs from the normal click() method. Can you share any HTML code for the element you are trying to click? A snapshot of the application would be nice too.

Sure you do. Right click on the element you are trying to click, and click “Inspect”.

You may have to select Inspect twice. The first time the code window shows, the second time the code window should zoom right to your selected Element.

Also, with the verifyTextPresent, you do not need to use Regular Expression, so you can set the Boolean to “false”, rather than “true”. And, once you get to look at the code, double click on the phrase, “Servicio General”, copy and paste that into the verifyTextPresent statement just in case there are additional spaces that cannot be seen but are a part of the actual phrase. Or, to use Regular Expression, add onto the end of “Sericio General” a period and asterisk, like “.*”

Also, the page we see above. Did you manually move to that page, or did KS do it?

@Brandon_Hein look, this part of the html works? at least that is the field that does not want to recognize me on the new window.

@helpdesk I already changed the boolean value to “false” and it didn’t work either.

Yes, exactly. Now, try testing an xpath for this element in your inspector:

1.) In your inspector, open the “Console” tab:

2.) Type the following into the console:


and see what comes back.

this is the result that it throws:

Perfect. Now create a test object for this:

and replace the WebUI.clickImage() with:'path/to/my/object'))

friend did not work. Look what comes out:

Instead of the delay(10) line, put this:

WebUI.waitForElementPresent(findTestObject('Act.Servi/new/prueba'), 30)

It didn’t work either

After the test fails, can you see the target element in the browser it was using? Does the xpath work in the console like above?

I noticed you have “switchToWindowTitle” within your test. Are you still within that pop-up or have you come back to the “main” page when you try to click on the image? The fact that the “verifyTextPresent” failed IMO means KS/you are NOT on the “correct” page, whichever that is.

Good morning,

@Brandon_Hein how can I see the target element? inspecting?

@helpdesk no, I already left the pop-up screen, the action opens is another different screen, where I must follow the flow of automation and that is where it does not find the element we are talking about.

I don’t know if this will help, however, after you have switchToWindowTitle(), I think you should also

“Switch back to default content”

Maybe insert the above statement before your “waitForElementPresent” statement that is on the “new” page that is not working.