SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.18k stars 8.11k forks source link

[🐛 Bug]: Not able to upload the File if Hasauthentication used in our Scripst #11890

Closed gitnithin closed 1 year ago

gitnithin commented 1 year ago

What happened?

I am using Cucumber framework with Java, For our app ,after we enter the URL , authentication popup appears to handel this i have tried with many methods finally i have used Hasauthentication to pass the credentials, there is one testcase to upload the files but i am not able to upload the files if we are not using the hasAuthentication it worked file

Note: i have used below methods but it fails to pass the credentials so i have used HASAUTHENTICATION

  1. pass the credentials in URL
  2. Pass the credentials via AutoIT
  3. Pass the credentials using ROBOT class

How can we reproduce the issue?

1. use hasauthentication to pass the credentials for login
2. Try to upload the file

Relevant log output

As testcase gets passed but file is not uploading so didn’t get any logs for that

Operating System

Windows10

Selenium version

4.7.2

What are the browser(s) and version(s) where you see this issue?

Chrome 111

What are the browser driver(s) and version(s) where you see this issue?

have used Driver Manager

Are you using Selenium Grid?

no

github-actions[bot] commented 1 year ago

@gitnithin, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

krmahadevan commented 1 year ago

@gitnithin - The latest released version of selenium is 4.8.3. Please retry using that. If it still is a problem then please help create a sample that can be used to reproduce the problem.

github-actions[bot] commented 1 year ago

Hi, @gitnithin. Please follow the issue template, we need more information to reproduce the issue.

Either a complete code snippet and URL/HTML (if more than one file is needed, provide a GitHub repo and instructions to run the code), the specific versions used, or a more detailed description to help us understand the issue.

Note: If you cannot share your code and URL/HTML, any complete code snippet and URL/HTML that reproduces the issue is good enough.

Reply to this issue when all information is provided, thank you.

diemol commented 1 year ago

Closing as we did not get more information.

VickyZebra commented 1 year ago

we are using selenium 4.11.0 with chrome driver, we encounter same issue

titusfortner commented 1 year ago

We need a reproducible example to debug it.

VickyZebra commented 1 year ago

How should I provide the example? our server is not a public server and it requests SSO which you can not access

titusfortner commented 1 year ago

What code are you using, a vague description of a problem for a feature that is generally working is insufficient. Can you turn on logging and give the output? There's nothing actionable in this issue right now.

VickyZebra commented 1 year ago

if I used the following method to avoid the login pop up ((HasAuthentication) driver).register(UsernameAndPassword.of(admin_usrname, admin_passwd));

I can not upload the local file to our web site by the following method(to simulate select a file from file browser to upload), the content is empty

    WebElement upload = driver.findElement(By.id("addResourceFileInput"));
    System.out.println("Files upload to resource: "+ResourceLoc.getAbsolutePath());
    upload.sendKeys(ResourceLoc.getAbsolutePath());

without ((HasAuthentication) driver).register(UsernameAndPassword.of(admin_usrname, admin_passwd)); everything works well

titusfortner commented 1 year ago

What are you using for the uriPredicate? https://www.selenium.dev/documentation/webdriver/bidirectional/bidi_api/#register-basic-auth

Perhaps you only need it to match the first interaction with the site and then do not want it after?

VickyZebra commented 1 year ago

still no luck after updating the codes: P.S the web url is: https://leopard.zpc-stage.zebra.com/ppme

        Predicate<URI> uriPredicate = uri -> uri.getHost().contains("leopard.zpc-stage.zebra.com");
        ((HasAuthentication) driver).register(uriPredicate, UsernameAndPassword.of(admin_usrname, admin_passwd));
github-actions[bot] commented 9 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.