Search code examples
javaleanft

LeanFT open browser window and navigate


I recorded a test case with Test Recorder tool in LeanFT with Chrome. When I execute it, it opens a new tab in Chrome, instead of starting a new instance of application. I tried to execute it in Firefox, but in this case it just opens browser window, doesn't navigate to given url.

    Browser browser = BrowserFactory.launch(BrowserType.FIREFOX);
    browser.navigate(env.LOGIN);

Error message:

com.hp.lft.sdk.GeneralLeanFtException: launch browser timeout occurred


Solution

  • When you execute a test, it's a new session.

    This means that it's your responsibility to make sure that the environment in which your code is running is appropriate.

    If you use .launch

    • while you have Chrome opened, it'll open a new tab
    • while you have Chrome closed, it'll open chrome (new window)
    • no matter if you have firefox opened or closed, it'll open a new firefox window

    As you can see, the same method causes different behavior, depending on the browser and the state of the environment during the execution.

    You need to adapt depending on your needs, and decide whether you want to .launch a browser or .attach to one.