2013-09-26 4 views
1

안녕하세요 저는 현재 자동화 된 QA (Splinter) 테스터가 Python을 사용하고 있다는 것을 처음 접했습니다. 프롬프트가 있는지 지불 페이지를 테스트 해보고 싶습니다. 필수 입력란이 비어있는 경우 메모장에 로그인하십시오.alert.accept()를 여러 번 사용하면 제대로 작동하지 않습니다.

내 문제는 alert.accept()을 두 번 사용하면 두 번째로 실행되지 않는다는 것입니다.

예 : 첫 번째 프롬프트는 "트랜잭션 유형 입력이 트랩 됨"이라고 예상 한 다음 alert.accept()을 사용하여 프롬프트를 닫습니다. 그러나 두 번째로 작동하지 않으면 프롬프트가 그대로 유지되고 alert.accept()을 사용할 때 자동으로 확인 버튼을 클릭하지 않습니다. 왜 이런거야? 같은 시간에 두 개의 알림을 사용하고있을 때 내가 놓친 규칙이 있습니까? 그런데

def checkTrappings(): 
    logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty') 
    browser.find_by_id('submitBtn').first.click() 
    alert = browser.get_alert() 
    x = str(alert.text) 
    if x == 'Transaction Type is required.': 
     logUtb(f, 'Transaction Type input is trapped') 
    alert.accept() 
    logUtb(f, "") 

    logUtb(f, 'Checking if email is a valid email') 
    browser.select('tranType','A') 
    browser.find_by_id('submitBtn').first.click() 
    alert = browser.get_alert() 
    x = str(alert.text) 
    if x == 'Please enter a valid email address.': 
     logUtb(f, 'Proper email format is trapped') 

    alert.accept() 
    logUtb(f, "") 

    browser.find_by_id('submitBtn').first.click() 
    alert = browser.get_alert() 
    x = str(alert.text) 

logUtb 내가 메모장

def logUtb(fl, strx): 
    now = datetime.datetime.now() 
    fl.write(now.strftime('%Y-%m-%d %H:%M') + " - " + strx + "\n"); 
    return; 
에 보고서를 기록 내 기능입니다

내가 사용하고 도서관은 내가 확인하는 두 가지 기능을함으로써 그것을 해결

+1

어떤 라이브러리를 사용하고 있습니까? – enginefree

+0

내가 사용하고있는 라이브러리가 파편입니다. – cor03rock

답변

0

파편입니다 다른 필드가 있지만 왜 나는 그것이 효과가 있었는지 잘 모르겠다. 그리고 나는 또한 그것을 좋아하지 않는다. 왜 같은 기능을 가지고 하나를 만들 수있을 때 두 가지 기능을 만들어야 하는가.

def checkTrapTransaction(): 
    try: 
     logUtb(f, 'Checking if Transaction type is trapped, making payment with Transaction type as empty') 
     browser.find_by_id('submitBtn').first.click() 
     alert = browser.get_alert() 
     x = str(alert.text) 
     if x == 'Transaction Type is required.': 
      logUtb(f, 'Transaction Type input is trapped') 
     alert.accept() 
     logUtb(f, "") 

    except: 
     logUtbE(f, "Exception: Please recheck your code") 

def checkTrapEmail(): 
    try: 
     logUtb(f, 'Checking if email is a valid email') 
     browser.select('tranType','A') 
     browser.find_by_id('submitBtn').first.click() 
     alert = browser.get_alert() 
     x = str(alert.text) 
     if x == 'Please enter a valid email address.': 
      logUtb(f, 'Proper email format is trapped') 

     alert.accept() 
     logUtb(f, "") 

    except: 
     logUtbE(f, "Exception: Please recheck your code") 

이 문제에 대한 다른 해결책이있는 경우 방금 전에 수정 한 내용이 마음에 들지 않아 제안에 답변을드립니다. 감사합니다