If Else being ignored

Asked

Viewed 62 times

1

I’m starting now on programming... I drove the Bugger and noticed that the if/else (# TKINTER RESULTS GRID) is being ignored, finishing the code without any error in the console. I tested some modifications but was not successful.

What could be causing the problem?

    try:
        if self.driver.find_element_by_xpath('/html/body/main[1]/nav/ul/li[1]/span').is_displayed():

            # DROPDOWN CLICK TO MAKE ITEMS VISIBLE
            self.driver.find_element_by_xpath('/html/body/main[1]/nav/ul/li[1]/span').click()

            time.sleep(1)

            dropd = self.driver.find_elements_by_xpath('/html/body/main[1]/nav/ul/li[1]/ul/li')
            print(len(dropd))

            i = 0

            for item in dropd:
                time.sleep(1)

                print(item.text)
                benef = item.text

                item.click()


                # CLIENT CODE HAVE NOTIFICATION
                if self.driver.find_element_by_xpath('//*[@id="notification"]').is_displayed():
                    ....

                # CLIENT CODE DOESN'T HAVE NOTIFICATION
                else:
                    ....

                # TKINTER RESULTS GRID
                if age < 75:
                    idade_plc = Label(frame_idade, text=age, borderwidth=1, relief="groove")
                    idade_plc.grid(row=i + 3, column=0, sticky=EW)
                elif age > 75:
                    idade_plc = Label(frame_idade, text=age, borderwidth=1, relief="groove", bg='red')
                    idade_plc.grid(row=i + 3, column=0, sticky=EW)

                benef_plc = Label(frame_benef, text=beneficio, borderwidth=1, relief="groove")
                ...

                if qnt >= 9:
                    qnt_plc = Label(frame_qnt, text=qnt, borderwidth=1, relief="groove", bg='red')
                    qnt_plc.grid(row=i + 3, column=0, sticky=EW)
                elif qnt < 9:
                    qnt_plc = Label(frame_qnt, text=qnt, borderwidth=1, relief="groove")
                    qnt_plc.grid(row=i + 3, column=0, sticky=EW)

                ...

                i += 1

                time.sleep(2)
                self.driver.find_element_by_xpath('/html/body/main[1]/nav/ul/li[1]/span').click()

    except:
        pass
  • Where would this "age" variable be? Because through the analysis of the programming logic, if/Lse would not run only if it acts 75

  • Important you [Dit] your question and explain objectively and punctually the difficulty found, accompanied by a [mcve] of your solution attempt. To better understand and enjoy the site is worth reading the Stack Overflow Survival Guide in English.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.