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

Allow using a Proxy #236

Merged
merged 12 commits into from
Apr 8, 2024
Merged

Allow using a Proxy #236

merged 12 commits into from
Apr 8, 2024

Conversation

thomhurst
Copy link
Contributor

Currently there is no way to use a proxy with playwright. This fixes that.

if (sessionConfiguration.Browser == Browser.Safari) {
throw new NotSupportedException("Safari does not support headless mode");
}
if (browser == Browser.Safari) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should've been checking for opera. Fixed it.

@adiel
Copy link
Member

adiel commented Mar 23, 2024

This looks good. Any thoughts on how we might test it? Is there a simple proxy for .Net we could run up in one Acceptance test to just confirm it's all wired up properly?

@thomhurst
Copy link
Contributor Author

This looks good. Any thoughts on how we might test it? Is there a simple proxy for .Net we could run up in one Acceptance test to just confirm it's all wired up properly?

Added a test: Driver_Uses_Proxy

Copy link
Collaborator

@sbowler sbowler left a comment

Choose a reason for hiding this comment

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

This mostly looks good to me other than a few minor things.

browser.Visit("http://www.example.com");

// So we then assert we can find the GitHub Octo Icon
var icon = browser.FindCss(".octicon-mark-github");
Copy link
Collaborator

@sbowler sbowler Mar 28, 2024

Choose a reason for hiding this comment

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

I'm a bit concerned this could break easily if they update their website. Not sure what would be a good alternative though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Have updated to render a page from localhost instead so we have full control

@@ -27,20 +26,41 @@ public PlaywrightDriver(SessionConfiguration sessionConfiguration)
_browser = sessionConfiguration.Browser;
_headless = sessionConfiguration.Headless;
var browserType = PlaywrightBrowserType(_browser, _playwright); // TODO: map browser to playwright browser type

Copy link
Collaborator

Choose a reason for hiding this comment

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

Pointless whitespace.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've run a dotnet format whitespace


var firefoxOptions = new FirefoxOptions
{
AcceptInsecureCertificates = sessionConfiguration.AcceptInsecureCertificates,
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm a bit surprised by this because I thought we already had a way to accept insecure certificates, but this seems to imply that wasn't the case.

}

private IWebDriver BrowserNotSupported(Browser browser,
Exception inner)
Exception inner)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure about this formatting change. I'm not sure what formatting settings this code base has if any, but certainly some of this seems unnecessary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was just automatically done by my editor. I haven't done this intentionally

{
throw new BrowserNotSupportedException(browser, GetType(), inner);
}
}
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you removed the newline at the end of the files

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Think I've re-added. Think the github diff is weird at showing them though

@adiel
Copy link
Member

adiel commented Apr 8, 2024

I think we can merge this now @sbowler ?

@sbowler
Copy link
Collaborator

sbowler commented Apr 8, 2024

I'm not a big fan of the 4 space indentation, but at least it appears you've made it more consistent so there's that. LGTM otherwise.

@sbowler sbowler merged commit 57dac0d into featurist:master Apr 8, 2024
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

Successfully merging this pull request may close these issues.

4 participants