Python Windows Authentication username and password is not working











up vote
4
down vote

favorite
1












I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?



from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()


I have tried with:



ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()


This one is also not working.










share|improve this question
























  • Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
    – Chai
    Jul 26 '17 at 13:48












  • tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
    – jaibalaji
    Jul 26 '17 at 13:53















up vote
4
down vote

favorite
1












I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?



from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()


I have tried with:



ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()


This one is also not working.










share|improve this question
























  • Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
    – Chai
    Jul 26 '17 at 13:48












  • tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
    – jaibalaji
    Jul 26 '17 at 13:53













up vote
4
down vote

favorite
1









up vote
4
down vote

favorite
1






1





I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?



from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()


I have tried with:



ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()


This one is also not working.










share|improve this question















I am trying to enter data in prompt (URL Given), below codes is giving me an error. Please help me out with these?



from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys
import time
driver = webdriver.Firefox()
url = "http://the-internet.herokuapp.com/basic_auth"
driver.get(url)
time.sleep(5)
alert = driver.switch_to.alert
alert.authenticate('admin','admin')
time.sleep(4)
alert.accept()


I have tried with:



ActionChains(driver).send_keys("admin").send_keys(Keys.TAB).send_keys("admin").perform()


This one is also not working.







python selenium selenium-webdriver windows-authentication basic-authentication






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 19 at 9:16









DebanjanB

36.5k73372




36.5k73372










asked Jul 26 '17 at 13:38









jaibalaji

1071110




1071110












  • Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
    – Chai
    Jul 26 '17 at 13:48












  • tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
    – jaibalaji
    Jul 26 '17 at 13:53


















  • Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
    – Chai
    Jul 26 '17 at 13:48












  • tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
    – jaibalaji
    Jul 26 '17 at 13:53
















Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
– Chai
Jul 26 '17 at 13:48






Not sure if this is your problem but the first thing I see is you forgot the "()" in alert = driver.switch_to.alert()
– Chai
Jul 26 '17 at 13:48














tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
– jaibalaji
Jul 26 '17 at 13:53




tried : alert = driver.switch_to.alert() TypeError: 'Alert' object is not callable
– jaibalaji
Jul 26 '17 at 13:53












2 Answers
2






active

oldest

votes

















up vote
6
down vote



accepted










When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.



This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.



from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")





share|improve this answer























  • thank you man :) it worked :)
    – jaibalaji
    Jul 26 '17 at 14:08










  • Sure. done man.
    – jaibalaji
    Jul 26 '17 at 14:11










  • FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
    – orde
    Jul 26 '17 at 18:34


















up vote
0
down vote













    def test_1_authentication(self):
self.driver.get("https://the-internet.herokuapp.com/basic_auth")
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{TAB}")
time.sleep(3)
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{ENTER}")
time.sleep(3)


Above code is also properly worked :)






share|improve this answer























  • works on Windows only
    – Corey Goldberg
    Mar 22 at 14:56










  • Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
    – Shoaib Akhtar
    Apr 3 at 10:26











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45328654%2fpython-windows-authentication-username-and-password-is-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
6
down vote



accepted










When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.



This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.



from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")





share|improve this answer























  • thank you man :) it worked :)
    – jaibalaji
    Jul 26 '17 at 14:08










  • Sure. done man.
    – jaibalaji
    Jul 26 '17 at 14:11










  • FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
    – orde
    Jul 26 '17 at 18:34















up vote
6
down vote



accepted










When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.



This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.



from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")





share|improve this answer























  • thank you man :) it worked :)
    – jaibalaji
    Jul 26 '17 at 14:08










  • Sure. done man.
    – jaibalaji
    Jul 26 '17 at 14:11










  • FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
    – orde
    Jul 26 '17 at 18:34













up vote
6
down vote



accepted







up vote
6
down vote



accepted






When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.



This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.



from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")





share|improve this answer














When you work with Selenium 3.4.0, geckodriver v0.18.0, Mozilla Firefox 53.0 through Python 3.6.1 you can bypass the Basic Authentication popup through embedding the username and password in the url itself as follows.



This solution opens the URL http://the-internet.herokuapp.com/basic_auth and authenticates with a valid username and password credentials.



from selenium import webdriver
from selenium.webdriver.firefox.firefox_binary import FirefoxBinary

binary = FirefoxBinary('C:\Program Files\Mozilla Firefox\firefox.exe')
driver = webdriver.Firefox(firefox_binary=binary, executable_path="C:\Utility\BrowserDrivers\geckodriver.exe")
driver.get("http://admin:admin@the-internet.herokuapp.com/basic_auth")






share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 20 at 11:43

























answered Jul 26 '17 at 14:02









DebanjanB

36.5k73372




36.5k73372












  • thank you man :) it worked :)
    – jaibalaji
    Jul 26 '17 at 14:08










  • Sure. done man.
    – jaibalaji
    Jul 26 '17 at 14:11










  • FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
    – orde
    Jul 26 '17 at 18:34


















  • thank you man :) it worked :)
    – jaibalaji
    Jul 26 '17 at 14:08










  • Sure. done man.
    – jaibalaji
    Jul 26 '17 at 14:11










  • FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
    – orde
    Jul 26 '17 at 18:34
















thank you man :) it worked :)
– jaibalaji
Jul 26 '17 at 14:08




thank you man :) it worked :)
– jaibalaji
Jul 26 '17 at 14:08












Sure. done man.
– jaibalaji
Jul 26 '17 at 14:11




Sure. done man.
– jaibalaji
Jul 26 '17 at 14:11












FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
– orde
Jul 26 '17 at 18:34




FWIW: embedded credentials will only partially work using chrome v59+ because sub-resource requests will be blocked.
– orde
Jul 26 '17 at 18:34












up vote
0
down vote













    def test_1_authentication(self):
self.driver.get("https://the-internet.herokuapp.com/basic_auth")
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{TAB}")
time.sleep(3)
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{ENTER}")
time.sleep(3)


Above code is also properly worked :)






share|improve this answer























  • works on Windows only
    – Corey Goldberg
    Mar 22 at 14:56










  • Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
    – Shoaib Akhtar
    Apr 3 at 10:26















up vote
0
down vote













    def test_1_authentication(self):
self.driver.get("https://the-internet.herokuapp.com/basic_auth")
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{TAB}")
time.sleep(3)
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{ENTER}")
time.sleep(3)


Above code is also properly worked :)






share|improve this answer























  • works on Windows only
    – Corey Goldberg
    Mar 22 at 14:56










  • Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
    – Shoaib Akhtar
    Apr 3 at 10:26













up vote
0
down vote










up vote
0
down vote









    def test_1_authentication(self):
self.driver.get("https://the-internet.herokuapp.com/basic_auth")
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{TAB}")
time.sleep(3)
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{ENTER}")
time.sleep(3)


Above code is also properly worked :)






share|improve this answer














    def test_1_authentication(self):
self.driver.get("https://the-internet.herokuapp.com/basic_auth")
shell = win32com.client.Dispatch("WScript.Shell")
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{TAB}")
time.sleep(3)
shell.Sendkeys("admin")
time.sleep(3)
shell.Sendkeys("{ENTER}")
time.sleep(3)


Above code is also properly worked :)







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 18 '17 at 18:03









Ratmir Asanov

2,8003822




2,8003822










answered Aug 7 '17 at 10:02









jaibalaji

1071110




1071110












  • works on Windows only
    – Corey Goldberg
    Mar 22 at 14:56










  • Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
    – Shoaib Akhtar
    Apr 3 at 10:26


















  • works on Windows only
    – Corey Goldberg
    Mar 22 at 14:56










  • Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
    – Shoaib Akhtar
    Apr 3 at 10:26
















works on Windows only
– Corey Goldberg
Mar 22 at 14:56




works on Windows only
– Corey Goldberg
Mar 22 at 14:56












Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
– Shoaib Akhtar
Apr 3 at 10:26




Is the above code working now? I found the same piece of code which was working well for me is not working now. I asked question about the same here stackoverflow.com/questions/49491048/…
– Shoaib Akhtar
Apr 3 at 10:26


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f45328654%2fpython-windows-authentication-username-and-password-is-not-working%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

"Incorrect syntax near the keyword 'ON'. (on update cascade, on delete cascade,)

Alcedinidae

RAC Tourist Trophy