I'm working with iFramed web(micro frontend), the iFrame wraps the entire body(element inside it), and I need to switch iFrame every time the page loads.
Given driver siteUrl
And call read('classpath:web/pages/login/login.feature@login_with_email') args
* def args = {main_menu: fleet-management, submenu: Truk}
And call read('classpath:web/internal/pages/dashboard/dashboard.feature@open_page') args
# LOAD NEW PAGE
* waitFor(iFrameId).switchFrame()
And click(pageA.elementA)
# LOAD NEW PAGE
* waitFor(iFrameId).switchFrame()
And click(PageB.elementB)
Since switchFrame will be used frequently, beforeStep will be a great solution.
I've done research :
Hook.java
@Override
public boolean beforeStep(Step step, ScenarioRuntime sr)
{
Runner.runFeature("classpath:utils/helper.feature@switch_frame", null, false);
}
helper.feature
Feature: Test Feature For Switch Frame
@switch_frame
Scenario: Switching focus to iFrame
* waitFor(iFrameId).switchFrame()
but right now I'm stuck, helper.feature called from hook.java unable to use any keywords(waitFor, switchFrame) and unable to get global variable set from karate-config.js.
Please help, Thanks!!