Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
337 views
in Technique[技术] by (71.8m points)

javascript - An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined with Selenium and Python

I am trying to use Selenium for Python eith the Chrome webdriver to automate the download of a file.

My program works perfectly up to the last step (clicking on the 'download' button) at which point a dialog box is triggered with the text:

"An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined41"

What does this error mean and what are the most probable causes?

For reference, here are the last few commands of my program:

try:
    elem = wait.until(EC.presence_of_element_located((By.ID,'element_1_id')))
finally:
    elem1 = driver.find_element_by_id('element_1_id')
    elem2 = driver.find_element_by_id('element_2_id')
    action = ActionChains(driver).move_to_element(elem1).move_to_element(elem2)
    action.perform()
    elem2.click()
Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This error message...

An error has occured in 'site url': Uncaught TypeError: Cannot read property 'getColomnSet' of undefined

...implies that your program was unable to read the property getColomnSet while trying to download the desired file.

Possibly, the main problem is the js involved to download the document is invoked before the client renders the HTML DOM completely.

The relevant HTML, a bit more of your previous lines of code and the error stack trace would have given us some more idea about what's going wrong.

Solution

  • You can induce some measures to wait till the complete DOM Tree is rendered following the discussion:
  • A couple of facts:
    • In your code trials I don't see you interacting with the element (By.ID,'element_1_id') so possibly you can remove the step of presence_of_element_located() for the element (By.ID,'element_1_id').
    • If you still require presence_of_element_located((By.ID,'element_1_id')) catch the exception and initiate required steps.
    • As you invoke move_to_element() over elem1 and elem2 and moving ahead invoke perform() you need to induce WebDriverWait with expected_conditions as element_to_be_clickable(locator)

tl;dr (references)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...