• 01-06-2022, 03:11:18
    #1
    Sorunum şu şekilde;

    Selenium ile bir xpathin olup olmadığını try except ile kontrol ediyorum ve değişkene true false atıyorum

    try:
      kayitolbuton
    except:
      hata = TRUE
    else:
      hata = FALSE
    Eğer hata var ise sonrasında bir butona basıp tekrar kontrol sağlamasını istiyorum, eğer bu döngü 10 kere devam ederse ve hala hata varsa programın dosyanın başından tekrar başlaması gerek.

    Başka bir şekilde kontrol edilebilirse öyle de kullanabilirim.
  • 01-06-2022, 03:36:01
    #2
    isDisplayed = driver.find_element_by_xpath("div").is_displayed()
    
    count = 0
    def isDisplayed():
    
        if isDisplayed == True:
            print("True")
        
        else:
            if 9 > count:
                isDisplayed()
                count = count +1
            else:
                exit()
  • 01-06-2022, 03:38:11
    #3
    kerem_d adlı üyeden alıntı: mesajı görüntüle
    isDisplayed = driver.find_element_by_xpath("div").is_displayed()
    
    count = 0
    def isDisplayed():
    
        if isDisplayed == True:
            print("True")
        
        else:
            if 9 > count:
                isDisplayed()
                count = count +1
            else:
                exit()
    Displayed olarak kullanım sağladığımda bazı durumlarda garip bir sorun yaşıyorum hocam, bu sebepten dolayı except kullanmak zorunda kalıyorum.
  • 01-06-2022, 03:45:00
    #4
    Bu şekilde yapabilirsin yeniden çalıştırma işinin daha iyi yöntemleri vardır os.system() den başka
    import os
    
    count = 0
    def isClicked():
        try:
            driver.find_element_by_xpath("div").click()
        except:
            if 9 > count: 
                isClicked()
                count = count+1
            else:
                os.system("filepath")
                exit()