Home>
I am currently studying page migration using selenium.
Here are the error statements.
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
I know the cause, but on the other hand I want to create an if statement that uses it.
That is,
if (for NoSuchElementException):
Move to another page
.
How can I do this?
-
Answer # 1
-
Answer # 2
I am a beginner, but I often use try/except.
# import library for exception handling from selenium.common.exceptions import NoSuchElementException try: The process you want to execute except NoSuchElementException: Processing when the above cannot be executed break
# Example when using if statement: # Conditional branch with or without specific element if len (driver.find_elements_by_class_name ('hoge'))>0: print ('Yes') else: print ('No')
I'm sorry if I didn't answer. . . . .
Related articles
- python - some pages cannot be accessed by routing branched in the list
- python - i don't see the error in the face cropping program with opencv
- python - i want to assign an element of one list to an element of another list
- python - a program that converts ordinal data to paired comparison data (i want to create a winning/losing matrix by turning a d
- python 3x - i want to daemonize a python program, but i want to see if this method works
- i want a program that uses watchdog to be automatically executed when a python computer is started
- adding an element to a particular line in a python 2d list
- python - background program by sharley method
- python - count by element with pivot_table in pandas
- how to write a python program for the fibonacci sequence
- i want to delete a partially matching element in a python array
- python - create a program to automatically take a screenshot of the kindle screen and save it
- python - i want to add an element to a double list
- python - i want to retrieve the element above the element searched by soupfind_all in beautiful soup
- python - selenium: element specification an error occurs in the code that can be executed once
- i want to see the change of one element of a recurrence formula including a python matrix
- please tell me how to write a program to end when the result is executed 5 times [python]
- python 3x - the program only works on the first line
- python - i can't get the element with selenium
- python 3x - i want to be able to run a scraping program created in python on a website
Related questions
- python : WebDriverException: Message: 'chromedriver' executable needs to be in PATH
- python : I don't know how to specify a filename when downloading a file from Selenium using Chrome
- python : No errors, script fails
- Python Selenium access to html code in dynamic iframe tag
- python how to use proxy with selenium [duplicate]
- python selenium how to use proxy
- python : The button "next" in Instagram on SELENIUM is not pressed
- python : Selenium does not work correctly with Firefox
- Is it possible to get the values of variables of a web page in Selenium (Python)
- python : Beautifulsoup + Selenium parser does not parse elements from the entire scrolling page (infinite scroll)
It looks like this.