1
나는 명시 적 대기를위한 메소드를 작성했다. 잘못된 로케이터는 내가 잘못된 포기하고 때 나는셀렌 + 파이썬에서 캐치 예외를 찾을 수 없음
여기에 또 다른 방법에서이 메서드를 호출하고
from Page_Objectes import Base_Page
from Tests.Base_Test_SSA import BaseTest
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common.exceptions import NoSuchElementException
class SynchronizationHelper(BaseTest):
# def __init__(self, _validate_page):
@staticmethod
def waitForElementToBeDisplayed(By, locator):
wait = WebDriverWait(BaseTest.driver, 60)
try:
if By == "XPATH":
wait.until(EC.presence_of_element_located((By.XPATH), locator))
elif By == "ID":
wait.until(EC.presence_of_element_located((By.ID), locator))
elif By == "CSS":
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR), locator))
except:
NoSuchElementException("Wrong Locator was given")
을 주어 졌을 때 나는 예외를 잡을 수 없습니까 그러나 xpath
여전히이
을 던지는되지 입니다NoSuchElementException ("잘못된 로케이터가 지정되었습니다")
아니, 난 어떤 예외가 발생하지 않았다. 나는 실제로 정적 메서드를 다른 메서드에서 호출하고 있습니다. –
질문을 편집하고 그 방법을 어떻게 부르는 지 보여줄 수 있습니까? – SilentMonk
또한 print 문을'except' 블록에 두어 예외가 있는지 확인하십시오. – SilentMonk