Elements can't be located in a print view modal window

Hello,

I have a trouble with locating an element in a modal with a shadow DOM (I’m not sure if the problem is related to shadow dom).
Could you please review the flow and advice what is wrong?

  1. test case (TC) starts in win 0
  2. TC opens win 1 ( print report functionality opens new browser page with print modal by default)

AR: test can work with elements on win 1 but can’t locate elements in opened modal print view window

Question: how to switch to modal?

Thank you in advance for your help!

1 Like

In the HTML that is presented, you have an <iframe> and I don’t see in your code a “WebUI.switchToFrame(findTestObject(‘…’), 10)” , so perhaps try that.

2 Likes

@grylion54 thank you for your answer.
the problem is that I can’t switch to the window (that contains iframe).

the window is opened as a new (with Print, Cancel buttons) but it is something I don’t know how to work with.
WebUI.switchToWindowIndex(i) is not an option. If it is Windows.switchToDesktop() could you please advise what parameters should be used to switch to this print window.

Thank you in advance for your help!

I don’t know why the switchToWindowIndex(i) is not an option; is it to do with the form being a Print form? I was just thinking of an experiment like:

try {
    pizzaLoop:
    for (int cnt = 1; cnt < 5; cnt++) {
        WebUI.switchToWindowIndex(cnt)

        if (WebUI.verifyTextPresent("Destination", false) || WebUI.verifyTextPresent("Layout", false)) {
            WebUI.comment("found the form on index ${cnt}")
            WebUI.switchToDefaultContent()
            break pizzaLoop;
         }
    }
} catch (Exception) {WebUI.comment("an error occurred instead") }

If the print form has a title, then you could try and use:
WebUI.switchToWindowTitle("Your Window Title")

thank you for your answer.
I have tried **switchToWindowIndex(i).
@grylion54 Could you please review the result?
there is “[1702647933.806][SEVERE]: Timed out receiving message from renderer: 30.000” when test tried to switch to WindowIndex(2).

Our dev has confirmed that it is default browser function to print (ctrl + p) the page. It is implemented to be opened by default (after click on functionality on win 0)

Thank you in advance for your help!

The following discussion may help you:

1 Like