1

I need to open the search windows on this page.

https://permits.losgatosca.gov/CitizenAccess/default.aspx

With firefox is working just fine, but when I try to do the same with phantomJS i got an error.

This is the code I'm using to open the search

BUTTON_id =  'ctl00_PlaceHolderMain_TabDataList_TabsDataList_ctl01_LinksDataList_ctl00_LinkItemUrl' #'//*[@id="ctl00_PlaceHolderMain_TabDataList_TabsDataList_ctl01_LinksDataList_ctl00_LinkItemUrl"]/span'
driver_1.switch_to_frame("ACAFrame")
button = driver_1.find_element_by_id(BUTTON_id)
button.click()

And this is the error I'm getting with phanthomJS:

Message: Error Message => 'Unable to switch to frame'

In this post it says that using:

driver.switchTo().frame(frame_index)
driver.switchTo().frame(frame_id)
driver.switchTo().frame(frame_object)

It solves the issue, but I don't know what to put in:

frame_index         
frame_id           
frame_object   

1 Answer 1

1

This is what you should try:

  • upgrade both selenium and PhantomJS to the latest versions
  • add a wait before switching to frame:

    from selenium.webdriver.common.by import By
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.support import expected_conditions as EC
    
    wait = WebDriverWait(driver, 10)
    wait.until(EC.presence_of_element_located((By.ID, "ACAFrame")))
    
    driver.switch_to.frame("ACAFrame")
    

(worked for me)

Sign up to request clarification or add additional context in comments.

4 Comments

Dis you test it on the page? I'm getting this error: raise TimeoutException(message, screen, stacktrace) selenium.common.exceptions.TimeoutException: Message: Screenshot: available via screen
@LuisRamonRamirezRodriguez yup, worked for me. I had an update in the answer, make sure u have tried the latest version of the answer
it worked just fine. Is there a way to optimize​ the waiting time?
@LuisRamonRamirezRodriguez great, how long does it take to wait for the frame to be present?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.