Skip to content

Commit

Permalink
deal with NoSuchElementException
Browse files Browse the repository at this point in the history
  • Loading branch information
wuyue92tree committed Nov 8, 2018
1 parent e90e2ba commit f61190b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crwy/utils/scrapy_plugs/middlewares.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"""

import json

import random
from scrapy.downloadermiddlewares.retry import RetryMiddleware
from scrapy_redis.connection import get_redis_from_settings
Expand Down
4 changes: 2 additions & 2 deletions crwy/utils/selenium_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
raise CrwyImportException(
"You should install selenium first! suggestion: pip install "
"selenium==3.6.0")
from selenium.common.exceptions import TimeoutException
from selenium.common.exceptions import TimeoutException, NoSuchElementException
from selenium.webdriver import DesiredCapabilities, ActionChains
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
Expand Down Expand Up @@ -233,7 +233,7 @@ def is_element_visible(self, element):
the_element = EC.visibility_of_element_located(element)
assert the_element(driver)
flag = True
except AssertionError:
except (AssertionError, NoSuchElementException):
self.logger.warning('the element is not visible.')
flag = False
except Exception as e:
Expand Down

0 comments on commit f61190b

Please sign in to comment.