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

Fix CDP download for custom browsers #2728

Merged
merged 1 commit into from
Apr 28, 2024

Conversation

PetroOv
Copy link

@PetroOv PetroOv commented Apr 25, 2024

Proposed changes

This PR fixes IllegalArgumentException for custom DriverProvider/DriverFactory when they support cdp

Checklist

  • Checkstyle and unit tests are passed locally with my changes by running gradlew check chrome_headless firefox_headless command
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@PetroOv PetroOv changed the title fix_cdp_download Fix CDP download for custom browsers Apr 25, 2024
@PetroOv PetroOv force-pushed the fix_cdp_download branch 2 times, most recently from 9161041 to 43364d0 Compare April 25, 2024 12:47
import org.openqa.selenium.WebDriver;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@PetroOv Please avoid massive changing order of imports. Let them rest in peace.

@@ -42,6 +49,7 @@ void openFileUploadForm() {
Configuration.remote = gridUrl.toString();
Configuration.browserCapabilities.setCapability("se:downloadsEnabled", true);
Configuration.fileDownload = CDP;
closeWebDriver();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it will slow down all previous tests.
Let's close the browser only in one test.

}
Optional<HasDevTools> cdpBrowser = cast(driver.getWebDriver(), HasDevTools.class);
if (cdpBrowser.isPresent()) {
DevTools devTools = cdpBrowser.get().getDevTools();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that Firefox doesn't support downloading files via CDP.
We need to exclude Firefox in this IF. @PetroOv

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know it( I returned isChromium check, but now we get browser name from capabilities of instance

@asolntsev asolntsev added this to the 7.3.0 milestone Apr 25, 2024
Copy link

sonarcloud bot commented Apr 26, 2024

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
0.0% Duplication on New Code

See analysis details on SonarCloud

@asolntsev asolntsev merged commit 41c6cda into selenide:main Apr 28, 2024
12 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants