Home>

Hello.
Python Selenium, but after logging in, a Javascript pop-up appears.
" I want to close the popup by clicking "".
However, an error occurs.
Is the class specification method wrong?

Please tell me who you understand.
Thank you.

<>↓





















<>↓

from selenium import webdriver

driver = webdriver.Chrome ("Selenium/chromedriver.exe")

driver = webdriver.Chrome () elem_username = driver.find_element_by_name ('id') elem_username.send_keys ('')
elem_password = driver.find_element_by_name ('passwd')
elem_password.send_keys ('**')
driver.find_element_by_class_name ('login-button'). click ()

driver.find_element_by_class_name ('png alpha trackingGA'). click () <>↓

NoSuchElementException Traceback (most recent call last)
in
12 driver.find_element_by_class_name ('login-button'). Click ()
13
--->14 driver.find_element_by_class_name ('png alpha trackingGA'). Click ()
15

~ \ Anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py in find_element_by_class_name (self, name)
562 element = driver.find_element_by_class_name ('foo')
563 "" "
->564 return self.find_element (by = By.CLASS_NAME, value = name)
565
566 def find_elements_by_class_name (self, name):

~ \ Anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py in find_element (self, by, value)
976 return self.execute (Command.FIND_ELEMENT, {
977 'using': by,
->978 'value': value}) ['value']
979
980 def find_elements (self, by = By.ID, value = None):

~ \ Anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ webdriver.py in execute (self, driver_command, params)
319 response = self.command_executor.execute (driver_command, params)
320 if response:
->321 self.error_handler.check_response (response)
322 response ['value'] = self._unwrap_value (
323 response.get ('value', None))

~ \ Anaconda3 \ lib \ site-packages \ selenium \ webdriver \ remote \ errorhandler.py in check_response (self, response)
240 alert_text = value ['alert']. Get ('text')
241 raise exception_class (message, screen, stacktrace, alert_text)
->242 raise exception_class (message, screen, stacktrace)
243
244 def _value_or_default (self, obj, key, default):

NoSuchElementException: Message: no such element: Unable to locate element: {"method": "css selector", "selector": ". png alpha trackingGA"}
(Session info: chrome = 78.0.3904.108)