Implementation of basic auth. for many browsers #320

Merged
merged 3 commits into from May 1, 2016

Projects

None yet

4 participants

@dimand58
Contributor

Now we can use

Selenide.open("http://somepage.org", "SomeDomain", "JohnLogin", "JohnPassword");

if we want to pass basic authentication.
Supported (and tested) browsers:

  1. IE11
  2. Chrome
  3. Firefox
  4. PhantomJs
  5. HtmlUnit

Additional:

  • UnsupportedOperationException added to catch() clause in getJavascriptErrors() method (specially for HtmlUnit)
  • Tests for Chrome, IE, PhantomJs disabled because executables are needed
@asolntsev
Member

@dimand58 Do we really need to disable CSP?
For example, we configure CSP policy, why not to test in via selenium tests?

myProfile.setPreference("security.csp.enable", false);

@asolntsev asolntsev merged commit e996546 into codeborne:master May 1, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@asolntsev asolntsev added a commit that referenced this pull request May 1, 2016
@asolntsev asolntsev #320 fix checkstyle issue aedd335
@asolntsev asolntsev added a commit that referenced this pull request May 2, 2016
@asolntsev asolntsev #320 fix checkstyle issue 48144be
@dimand58
Contributor
dimand58 commented May 4, 2016

@asolntsev
I checked security.csp.enable in corporate network - it is useless proprety which have no influence on basic auth

@asolntsev
Member

@dimand58 yes, it's useless for basic auth, but probably it's useful for something else? Do we really need to disable it?

@shimkiv shimkiv commented on the diff Aug 9, 2016
src/main/java/com/codeborne/selenide/impl/Navigator.java
}
SelenideLog log = SelenideLogger.beginStep("open", url);
try {
WebDriver webdriver = getAndCheckWebDriver();
webdriver.navigate().to(url);
+ if (isIE()) Selenide.switchTo().alert().authenticateUsing(new UserAndPassword(domain + login, password));
@shimkiv
shimkiv Aug 9, 2016 Contributor

Hey Guys,
in case if BasicAuth is not required then exception will be thrown since we will not be able to switch to alert.
We should handle this case inside an additional try-catch block (without exception throwing) or introduce the new Configuration property

@simple-elf
simple-elf Aug 9, 2016 edited Contributor

Bug confirmed in #366
Created pull request #369

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment