1

Authentication popup

Here is my code:

def cloudtest(url,username, pw):
    driver = webdriver.Chrome()
    driver.get(url)
    driver.find_element_by_xpath("//input[@name = \"username\"]").send_keys(username)
    driver.find_element_by_xpath("//input[@name = \"password\"]").send_keys(pw)
    driver.find_element_by_xpath('//button[@type="submit"]').click()
    time.sleep(5)
    alert = driver.switch_to.alert()
    alert.send_keys(username)
    alert.send_keys(Keys.TAB)
    alert.send_keys(pw)

Actually, I've to enter the credentials twice, once when I hit the URL and once after clicking on Login. When login is clicked, I get popup asking for the credentials again.

I tried the above code, I get an error at switch_to.alert() stating that there is no alert.

"selenium.common.exceptions.NoAlertPresentException: Message: no such alert"

Suggestions please?

frianH
  • 7,295
  • 6
  • 20
  • 45
Vignesh Vicky
  • 31
  • 1
  • 4

1 Answers1

2

After multiple iteration, i was able to get to it. I get many blog that explains mostly on the Selenium Web driver with Java. But, here is a way you can do that in python.

Just split the URL like below in line 8:

driver = webdriver.Chrome()
driver.get(url)
driver.find_element_by_xpath("//input[@name = \"username\"]").send_keys(username)
driver.find_element_by_xpath("//input[@name = \"password\"]").send_keys(pw)
driver.find_element_by_xpath('//button[@type="submit"]').click()
time.sleep(5)
url = "https://" + username + ":" + pw + "@" + "planning3-test-epmdevams.pbcs.em2.oraclecloud.com/aps/Test"
driver.get(url)
Vignesh Vicky
  • 31
  • 1
  • 4