Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I am using Selenium in Python to navigate to a website and fill in a form. There is a section of the code that let's you click on a button to open a pop-up node tree using javascript. I am able to click the button using the following code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
driver = webdriver.Ie("C:\\IEDriverServer.exe")
driver.get('htto://someurl.com')
popup = driver.find_element_by_xpath('//a[@onclick and @href = "javascript:;" and img/@alt = "Node Tree"]')
popup.click()
driver.switch_to.alert

At this point, everything on website becomes unclickable both in the pop-up box and on the actual site. What is causing this? Unfortunately I can't share the Javascript as it's internal to my company.

share|improve this question
    
Have you tried driver.switch_to.alert? –  alecxe Jul 29 '14 at 19:19
    
@alecxe I just added that line to the original post. When I try to click anything, I am still getting the black circle with the line through it (meaning I can't click anything). I'm not sure why clicking that button through Selenium is any different then manually clicking it. Also this is not a true popup in that it's not a separate window. –  user2242044 Jul 29 '14 at 19:47

1 Answer 1

rather than switch_to.alert, how about drv.switch_to_alert() where drv is your driver instance.

I can't see anything in the python source that's immediately obvious by grepping that looks like the switch_to. syntax is supported.

I would have posted a comment, but I don't have the reputation to do so.

share|improve this answer
    
No luck with this. PyCharm actually recommends the switch. –  user2242044 Jul 29 '14 at 20:28

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.