1

I am currently testing the UI of a PEGA application whereas I have stumbled on an issue where I am clicking a button that in its turn saves an item and closes the frame. When click method is finished it is still looking for frame y but stands on frame x, so it crashes.

The issues followed by this is when using:

driver.findElement(By.x("selector")).click(); 

frame is switching and in the framework its still trying to locate the previous active frame (which is not visible at this time).

Im on frame PegaGadget2Ifr but ends up on PegaGadget1Ifr curing click.

This is what code im running:

    public void saveProjectAsDraft(){
        Project_page pp = new Project_page(FDMPortal.getActiveFrameId(true), testEnv);
        FDMObjectsBean.setProject_page(pp);
        pp.saveDraft();
    }

public Workplace_details_page saveDraft(){
        findElement(SAVE_DRAFT).click();
        return new Workplace_details_page(getActiveFrameId(true),testEnv);
    }

getting this error message.

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#PegaGadget2Ifr"}
  (Session info: chrome=99.0.4844.74)
For documentation on this error, please visit: https://www.seleniumhq.org/exceptions/no_such_element.html
os.version: '10.0', java.version: '1.8.0_312'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 99.0.4844.74, chrome: {chromedriverVersion: 99.0.4844.51 (d537ec02474b5..., userDataDir: x, goog:chromeOptions: {debuggerAddress: localhost:63949}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: WINDOWS, platformName: WINDOWS, proxy: Proxy(), setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: x
*** Element info: {Using=id, value=PegaGadget2Ifr}
    at sun.reflect.GeneratedConstructorAccessor16.newInstance(Unknown Source)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:187)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:122)
    at org.openqa.selenium.remote.http.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:49)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:158)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:323)
    at org.openqa.selenium.remote.RemoteWebDriver.findElementById(RemoteWebDriver.java:372)
    at org.openqa.selenium.By$ById.findElement(By.java:188)
    at org.openqa.selenium.remote.RemoteWebDriver.findElement(RemoteWebDriver.java:315)
    at com.pega.framework.PegaWebDriverImpl.switchToActiveFrame(PegaWebDriverImpl.java:613)
    at com.pega.framework.PegaWebElementImpl.click(PegaWebElementImpl.java:513)
    at com.pega.framework.PegaWebElementImpl.click(PegaWebElementImpl.java:407)
    at com.pega.crm.workobjects.Project_page.saveDraft(Project_page.java:166)
    at stepdefs.WorkplaceStepDefs.saveProjectAsDraft(WorkplaceStepDefs.java:390)```
Blenk
  • 11
  • 2

2 Answers2

0

First switch to the frame where the element is present and then perform activity on the element. Use one of the available method

switchTo().frame(Index)
switchTo().frame(Web Element)
switchTo().frame(Id or name)
  • Hi, Thanks for your response. I am currently on the active frame where element is present. I Issue occurs when actually clicking the element. The click is performed so actual task is done, while clicking the current frame closes before method is finalized so somewhere during the process it will call for the previous active frame. – Blenk Apr 07 '22 at 10:14
0

As the previous frame PegaGadget2Ifr closes, an ideal approach would be to switch to the default Content first:

driver.switchTo().defaultContent();

and then attempt to switch to PegaGadget1Ifr frame.

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • 1
    Hi, And thanks for the quick response. – Blenk Apr 07 '22 at 09:08
  • I tried what you suggested and it didnt work for me sadly. I believe my issue is non related to switching between frames manually. So basically click is performed on PegaGadget2Ifr during the methodcall frame switches to PegaGadget1Ifr, when methodcall ended im standing on PegaGadget1Ifr but call method tries to locate PegaGadget2Ifr. If i understand correctly i need to switch to another frame while clicking, not before or after? – Blenk Apr 07 '22 at 09:19