2

If the text i am printing from that element is the correct the code just passes over it

     for items2 in ListaPlajePariuri:
         NumePlaje = items2.find_element_by_class_name(
                                    'KambiBC-bet-offer-category__title js-bet-offer-category-title')
         TotalGoluri = items2.find_elements_by_class_name(
                                    'KambiBC-bet-offer-subcategory KambiBC-bet-offer-subcategory--overunder')
         print(NumePlaje.text)


         if NumePlaje.text == 'Timp regulamentar' :
             input("why will you not work?")
             NumePlaje.click()

here is a printscreen with the output from print(NumePlaje.text), which seems to be good

enter image description here

6
  • Maybe the text has a trailing space? Try printing it like this: print('|%s|' % NumePlaje.text) Commented Sep 17, 2017 at 15:02
  • Printscreen output is hard to read. When you post text in your SO questions please do it the way you did you Python code. Commented Sep 17, 2017 at 15:04
  • Following the idea of @JohnGordon, you could test for that string using if 'Timp regulamentar' in NumePlaje.text:. This way it wouldn't matter what else is in NumePlaje.text. Commented Sep 17, 2017 at 15:07
  • @JohnGordon this is the new output |Timp regulamentar |, and i tried to compare it with this one and still passes over it Commented Sep 17, 2017 at 15:08
  • @BillBell your suggestion worked, if you write an answer i will accept it, thanks Commented Sep 17, 2017 at 15:13

1 Answer 1

1

I will withdraw this answer if John Gordon indicates that he wants to answer.

John Gordon pointed out that the variable NumePlaje.text might have trailing white space. This being the case, a simple test for NumePlaje.text == 'Timp regulamentar' would fail even if the variable contained that string.

Then a test for the presence of this string should be:

if 'Timp regulamentar' in NumePlaje.text:

This version of the if asks whether the string appears anywhere within the variable.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.