Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to define capabilities for multiple browsers through Serenity.conf #2966

Closed
sandeepraina-lenze opened this issue Nov 11, 2022 · 5 comments

Comments

@sandeepraina-lenze
Copy link

Hello,

At the moment I can successfully define/configure the single browser with capabilities as per W3C standards. But want to know how the same can be done for 2 different browsers e.g. one for Chrome and another for Firefox inside the same conf file. Below is my current Serenity.conf which I want to update to support multiple browsers.

webdriver {
  driver = "${driver}"
  autodownload = true

  timeouts {
#     implicitlywait = 15000
#     fluentwait = 15000
    script = 30000
    pageLoad = 300000
    implicit = 15000
  }

  capabilities {
    browserName = "chrome"
    acceptInsecureCerts = true
    "goog:chromeOptions" {
      args = ["start-maximized", "test-type", "no-sandbox", "ignore-certificate-errors", "disable-popup-blocking", "disable-default-apps", "disable-extensions-file-access-check", "incognito", "disable-infobars", "disable-gpu", "user-agent=Apache", "disable-dev-shm-usage", "window-size=1920,1080", "enable-features=NetworkService"]
    }
  }
}

serenity {
  take.screenshots = FOR_EACH_ACTION
  linked.tags = "issue"

  project.name = "${reporttitle}"
  compress.filenames = false
#   screenshooter = shutterbug1x

  browser {
    maximized = true
  }

  report {
    tagtypes="capability,feature"
    hide.empty.requirements = true
    exclude.tags="startrecording,staging,reset,stoprecording,notdeployed,debug,singlebrowser"
  }
}

#
# Report config
#
environments {
  with_screenshots {
    serenity {
      take.screenshots = BEFORE_AND_AFTER_EACH_STEP
    }
  }
}

shutterbug {
    capturestrategy = FULL
    betweenScrollTimeout = 100
    useDevicePixelRatio = true
}
@sandeepraina-lenze
Copy link
Author

Hello,

I was able to resolve the described issue by configuring the serenity.conf as follow:

environments {
    chrome {
        webdriver {
          driver = "chrome"
          autodownload = true

          timeouts {
            script = 30000
            pageLoad = 300000
            implicit = 15000
          }

          capabilities {
            browserName = "chrome"
            acceptInsecureCerts = true

            "goog:chromeOptions" {
              args = ["start-maximized", "test-type", "no-sandbox", "ignore-certificate-errors", "disable-popup-blocking", "disable-default-apps", "disable-extensions-file-access-check", "incognito", "disable-infobars", "disable-gpu", "user-agent=Apache", "disable-dev-shm-usage", "window-size=1920,1080", "enable-features=NetworkService"]
            }
          }
        }
    }

    firefox {
        webdriver {
          driver = "firefox"
          autodownload = true

          timeouts {
            script = 30000
            pageLoad = 300000
            implicit = 15000
          }

          capabilities {
            browserName = "firefox"
            acceptInsecureCerts = true

            "moz:firefoxOptions" {
              args = ["-private"],
              prefs {
                "browser.tabs.documentchannel.ppdc": false
                "browser.tab.animated": false
                "browser.panorama.animate_zoom": false
                "network.dns.disablePrefetch": true
                "network.prefetch-next": false
                "network.http.speculative-parallel-limit": 0
                "webgl.disabled": true
                "network.http.pipelining": true
                "network.http.proxy.pipelining": true
                "network.http.pipelining.maxrequests": 8
                "network.http.max-connections": 96
                "network.http.max-connections-per-server": 32
                "network.dns.disableIPv6": false
                "plugin.expose_full_path": true
                "nglayout.initialpaint.delay": 0
              }
            }
          }
        }
    }
}

@prashantrbs
Copy link

Hello Sandeep, i have similar requirement i want to run my test in firefox and chrome browser in docker compose i tried multiple ways could not able to achieve. This is file serenity.config file

webdriver {
      driver = remote
      remote {
            url="http://localhost:4444/wd/hub"
            driver=chrome
        }
    }

webdriver {
      driver = remote
      remote {
            url="http://localhost:4445/wd/hub"
            driver=firefox
        }
    }

When i run script tests are running only on firefox not on both browser please let me know if you have any solution.

Thanks in advance

@sandeepraina-lenze
Copy link
Author

sandeepraina-lenze commented Nov 25, 2022

Hello Sandeep, i have similar requirement i want to run my test in firefox and chrome browser in docker compose i tried multiple ways could not able to achieve. This is file serenity.config file

webdriver {
      driver = remote
      remote {
            url="http://localhost:4444/wd/hub"
            driver=chrome
        }
    }

webdriver {
      driver = remote
      remote {
            url="http://localhost:4445/wd/hub"
            driver=firefox
        }
    }

When i run script tests are running only on firefox not on both browser please let me know if you have any solution.

Thanks in advance

I guess for you the same example can also work which helped me to solve the multiple environment issue

environments {
    chrome {
		webdriver {
		  driver = remote
		  remote {
				url="http://localhost:4444/wd/hub"
				driver=chrome
			}
		}
	}

    firefox {
		  webdriver {
		  driver = remote
		  remote {
				url="http://localhost:4445/wd/hub"
				driver=firefox
			}
		}
    }
}

and then add -Denvironment=chrome or -Denvironment=firefox with your maven command

I hope this helps

@prashantrbs
Copy link

Hi Sandeep thanks for your time. i tried this but it did not work as expected.

@jecardenasri01
Copy link

HI,
You can comment all serenity.conf?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants