How to switch tabs and have Fitnesse load correct DOM?

It's critical to be able to tell Fitnesse to reload the DOM and move to a tab that is opened by the application.  How do we do this in Fitnesse?

Please don't include any UX recommendations for not opening new tabs just looking for an answer as to whether it's possible and if so how.

Here is the same question with no answer from 5 years ago.

 How to switch to new tab in fitnesse for Appian 

  Discussion posts and replies are publicly visible

  • 0
    Certified Associate Developer

    Hey Reid, I am running into the same issue. I have seen people suggesting to use Java to create a custom class/method to switch to the new tab but I am having issues getting it to run.

    Did you by any chance find a solution to this?

  • 0
    Certified Lead Developer
    in reply to siddharthas7035

    What kind of issues are you experiencing? Maybe we can help if you facilitate more info about them

  • 0
    Certified Associate Developer
    in reply to David J (NTT DATA)

    Hey David. Thanks for the reply.

    So I created a java class using selenium, exported it as JAR and saved it in "/lib" folder along with the other JAR files. I tried calling it into the FitNesse script using the following syntax, where "appianTest" is the package name, "openSite" is the class name and "getSite" is the method name.

    !|script                                                |
    |appianTest.openSite|getSite|with|https://www.google.com|


    But I run into "could not find class" error.

    For reference this is the Java code I am using.

    package appianTest;
    
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.chrome.ChromeDriver;
    
    public class openSite {
    	
    	public void getSite(String URL) {
    
    		WebDriver driver = new ChromeDriver();
    
    		driver.get(URL);
    	
    }
    }



    This is just a test code to see if I could create the custom Java class get it to work in FitNesse and not the code to switch tabs.

  • 0
    Certified Lead Developer
    in reply to siddharthas7035

    Do you have more information about the error? Did you check if there is more info in logs?

  • 0
    Certified Associate Developer
    in reply to David J (NTT DATA)

    Not really, when I look at the execution log I see these Warnings, but none of them are related to the "Could not find class appianTest". I have other test cases that are running successfully but give the same warning.

    Standard Output:

    WARNING: A terminally deprecated method in java.lang.System has been called
    WARNING: System::setSecurityManager has been called by fitnesse.slim.instructions.SystemExitSecurityManager (file:/C:/fitnesse-for-appian-23.4.1/lib/fitnesse-20230503-standalone.jar)
    WARNING: Please consider reporting this to the maintainers of fitnesse.slim.instructions.SystemExitSecurityManager
    WARNING: System::setSecurityManager will be removed in a future release

    Standard Error:

    ERROR StatusLogger Reconfiguration failed: No configuration found for '73d16e93' at 'null' in 'null'
    
    Mar 19, 2024 8:37:45 AM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
    WARNING: Unable to find CDP implementation matching 122
    
    Mar 19, 2024 8:37:46 AM org.openqa.selenium.chromium.ChromiumDriver lambda$new$5
    WARNING: Unable to find version of CDP to use for 122.0.6261.128. You may need to include a dependency on a specific version of the CDP using something similar to `org.seleniumhq.selenium:selenium-devtools-v86:4.11.0` where the version ("v86") matches the version of the chromium-based browser you're using and the version number of the artifact is the same as Selenium's.
    

  • No, I have not found a solution. Our workaround is to open the tab on login. If a tab is opened by the application, for example, a link or button click, rather than clicking on the link or button, we log out and log in again, specifying the URL of the target tab, or alternatively, we use the open URL instead of the click on a link or button click. 

  • 0
    Certified Lead Developer
    in reply to siddharthas7035

    And did you make a test with the java code directly (without using the script)? does it work?

  • 0
    Certified Associate Developer
    in reply to David J (NTT DATA)

    Yes, there is a slight syntax error in the code I posted, but after fixing it on my local machine I can run the code with no issues. Also, the error I am getting is not related to the working of the java code. Since the error says "Could not find class appianTest", I am assuming it is not even able to detect the java class to run it. 

  • 0
    Certified Associate Developer
    in reply to Avo Reid

    Oh okay, gotcha. But, just to be clear this URL is static isn't it? If I'm running test cases such as creating of a new candidate and I want to open the candidate details (which opens in a new tab), I will have to specify the URL manually for different candidates right? Or is there any way that you are dynamically inputting the URL based on the link or button click?