Reputation: 33
I am using Selenium Webdriver with Python for automation testing. While login my application I have got popup message for clicking 'OK' button. where i have used
from selenium import webdriver
def cbs_login():
browser = webdriver.Firefox()
browser.get('172.20.31.1:7085/web/ccp/login')
user = browser.find_element_by_css_selector('#userid')
user.send_keys('admin')
password = browser.find_element_by_css_selector('#password')
password.send_keys('admin2')
login_location = browser.find_element_by_css_selector('#loginlocation')
login_location.click()
location_name = browser.find_element_by_xpath('/html/body/div[2]/div/div/div/div/div/form/div/div/div/div/table/tbody/tr[4]/td/select/option[3]')
location_name.click()
driver.switchTo().alert().accept();
cbs_login()
i can't use the code ,I am getting error like "unresolved reference" Please mention is there any alternate way to handle it by python 2.7 version.
Upvotes: 3
Views: 4543
Reputation: 875
Please replace driver in as told by @andersson
driver.switch_to.alert.accept()
as browser and try
browser.switch_to.alert.accept()
Upvotes: 0
Reputation: 52665
switchTo()
is not a Python
method. You should try
browser.switch_to.alert.accept()
Also make sure that you have correctly import WebDriver
Upvotes: 2