We want to perform page processing based on the existence of class.
If class "bonus" exists and I want to confirm by printing "Yes":
# Class "bonus" actually exists but not printed if driver.find_element_by_class_name ("bonus") == True: print ("Yes") # Error below if len (driver.find_element_by_class_name ("bonus"))>0: print ("Yes") TypeError: object of type 'WebElement' has no len () # Using try will print correctly try: driver.find_element_by_class_name ("bonus") print ("Yes") except: print ("No") Yes
I would like to process with an if statement without using a try. Is this possible?
I'm sure it's a naive question, but I'd be happy if you could tell me.
Thanks for your cooperation.
Answer # 1
How about using the following method?
Since the return value is a list, is it possible to determine the presence or absence of the target tag by obtaining its length?
- python: i want to check the match of the elements of the data frame
- i want to do something like a function pointer in a class in python
- python 27 - i want to check if | is included in the string in python
- in python selenium, i want to get the element of the button of the site from class name, but it fails with nosuchelementexceptio
- read a python text file and get n lines from the line starting with the specified string
- python - output of private variables of class, list in class
- python - i want to calculate the radius of curvature of the specified graph
- python - i want to check the value stored in each object with django (= i want to debug)
- python 3x - i want to check if it is connected to the python3 server
- python - draw a specified number of straight lines at equal intervals
- python 3x - class variables do not increase
- python - i want to resolve the error "class has no member"
- python 3x - python i want to display only files with the specified extension
- how to apply the localetextcalendar class in the python standard library calendar
- python - i want to change the csv file name every time i loop with the for in syntax and save it in the specified folder
- python - about the specified position of pop ()
- python - i want to search for a specific value in a row specified by a two-dimensional array
- python - read_excel specified range column cannot be read
- python - 3 class classification by keras
- python 3x - how to use python class
- python 3x - i can't get the text of the span tag using selenium
- python 3x - i want to open the csv file downloaded with selenium web driver with pandas
- datetime - i want to use python, seleniumu to enter the date in the hp text box
- web scraping in python:error in send_keys
- chrome - i want to operate chromium with selenium
- i want to save pdf with name with python selenium
- python - cannot execute selenium on web (cgi)
- python 3x - python, selenium, radio button cannot be selected
- i want to upload a csv file at jupyter labo
- python 3x - i want to stop the browser that is already running on selenium