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

Incorrect equals check for "microsoft edge" browser if driver instance is of RemoteWebDriver in takeFullPageScreenshot method in Browser class #92

Closed
racchouhan12 opened this issue Apr 28, 2021 · 6 comments
Assignees

Comments

@racchouhan12
Copy link

racchouhan12 commented Apr 28, 2021

For MicrosoftEdge when I run on BrowserStack, RemoteWebDriver is used and screenshot which I get has overlapping as header in my page is fixed.
After debugging I noticed that when WebDriver is instance of RemoteWebDriver, the browser name I am getting is "msedge" not "MicrosoftEdge" hence takeFullPageScreenshot is not working as expected for MicrosoftEdge.
Here is the code from Browser class:

public BufferedImage takeFullPageScreenshot() { this.driver = this.unwrapDriver(); if (!(this.driver instanceof ChromeDriver) && !(this.driver instanceof EdgeDriver)) { if (this.driver instanceof FirefoxDriver) { return this.takeFullPageScreenshotGeckoDriver(); } else { if (this.driver instanceof RemoteWebDriver) { if (((RemoteWebDriver)this.driver).getCapabilities().getBrowserName().equals("chrome") || ((RemoteWebDriver)this.driver).getCapabilities().getBrowserName().equals("MicrosoftEdge")) { return this.takeFullPageScreenshotChromeCommand(); }

@glibas
Copy link
Member

glibas commented Apr 28, 2021

Hi @racchouhan12 ,

Please provide the following:

  • Browser version
  • Driver version
  • Selenium version
    used as well as the code snippet you are executing.

@glibas glibas self-assigned this Apr 28, 2021
@racchouhan12
Copy link
Author

MicrosoftEdge Version: 90.0.818.49
Edge Driver version: 4.0.0-beta-3
Selenium Version: 3.141.59

snippet:
try { scrollPageVerticallyTillBottom(driver); scrollToTop(driver); WaitUtil.nap(1); File destinationFile = new File(screenshotDir); destinationFile.getParentFile().mkdirs(); Shutterbug.shootPage(driver, Capture.FULL).withName(screenshotFileName).save(screenshotDir); logger.debug("screenshot taken and stored at " + destinationFile.getAbsolutePath()); } catch (Exception var5) { logger.error(var5.getMessage(), var5); }

@glibas
Copy link
Member

glibas commented Apr 28, 2021

Could you please also post the snippet of code of driver creation

@glibas glibas closed this as completed in fd0da6f Apr 28, 2021
@racchouhan12
Copy link
Author

racchouhan12 commented Apr 28, 2021

if (driverHost.contains("browserstack")) {
            capabilities = new DesiredCapabilities();
            capabilities.setCapability("browserName", System.getProperty("browserName"));
            capabilities.setCapability("browserstack.idleTimeout", System.getProperty("browserStack.idle.timeout"));
            HashMap browserstackOptions;
            if (isPdfJsDisabled && System.getProperty("browserName").toLowerCase().contains("chrome")) {
                //chrome option
                capabilities.setCapability("goog:chromeOptions", options);
            }

            if (isPdfJsDisabled && System.getProperty("browserName").toLowerCase().contains("firefox")) {
               //firefox option
                capabilities.setCapability("firefox_profile", profile);
            }

            if (System.getProperty("browserName").toLowerCase().contains("safari")) {
                SafariOptions options = new SafariOptions();
                capabilities.setCapability("safari.options", options);
            }

            capabilities.setCapability("browserVersion", System.getProperty("browserVersion"));
            browserstackOptions = new HashMap();
            browserstackOptions.put("os", System.getProperty("os"));
            browserstackOptions.put("osVersion", System.getProperty("osVersion"));
            browserstackOptions.put("local", System.getProperty("local"));
            browserstackOptions.put("userName", System.getProperty("uame"));
            browserstackOptions.put("accessKey", System.getProperty("key"));
            browserstackOptions.put("debug", System.getProperty("debug"));
            browserstackOptions.put("video", System.getProperty("video"));
            browserstackOptions.put("seleniumLogs", System.getProperty("seleniumLogs"));
            browserstackOptions.put("seleniumVersion", System.getProperty("seleniumVersion"));
            capabilities.setCapability("bstack:options", browserstackOptions);
            capabilities.setCapability("build", System.getProperty("build"));
            capabilities.setCapability("project", System.getProperty("test.project"));
            capabilities.setCapability("name", methodName);
            capabilities.setCapability("resolution", System.getProperty("resolution"));
            

            return new RemoteWebDriver(new URL(driverHost), capabilities);
			}

Here "browserName" I am passing is "MicrosoftEdge" in my testng.xml

@racchouhan12
Copy link
Author

racchouhan12 commented Apr 28, 2021

@glib-briia are you planning to release this change anytime soon?

@glibas
Copy link
Member

glibas commented Apr 28, 2021

@racchouhan12 released. Will be available in maven central in couple hours.

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

2 participants