Skip to content

Fix CDP download for custom browsers#2728

Merged
asolntsev merged 1 commit intoselenide:mainfrom
PetroOv:fix_cdp_download
Apr 28, 2024
Merged

Fix CDP download for custom browsers#2728
asolntsev merged 1 commit intoselenide:mainfrom
PetroOv:fix_cdp_download

Conversation

@PetroOv
Copy link
Copy Markdown
Contributor

@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
Copy Markdown
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.

Configuration.remote = gridUrl.toString();
Configuration.browserCapabilities.setCapability("se:downloadsEnabled", true);
Configuration.fileDownload = CDP;
closeWebDriver();
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor 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
@sonarqubecloud
Copy link
Copy Markdown

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
PetroOv pushed a commit to PetroOv/selenide that referenced this pull request Mar 25, 2025
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.

3 participants