K
K
Keepomen2019-03-20 10:02:54
Python
Keepomen, 2019-03-20 10:02:54

Actions and conditional checks with found elements, how to implement?

Using the command:

day=driver.find_elements_by_xpath('//*[starts-with(@id, "td_")]/td[3]/span[1]')
    for list_day in day:
    print(int(list_day.text))

I get about hundreds of unique digits from a new line in the console:
S9fWN.png
Instead of digits, I want to get information that each found element (digit) is greater or less than the previous one. Any ideas how to implement this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya, 2019-03-20
@Keepomen

buffer = 0
for list_day in day:
    if int(list_day.text) > buffer:
           print('больше')
    elif int(list_day.text) < buffer:
           print('меньше')
    else:
           print('равен')
    buffer = int(list_day.text)

R
Roman, 2019-03-20
@skipirich

for index, day in enumerate(list_day):
    if int(list_day[index]) < int(list_day[index - 1]):
        .........меньше
    elif int(list_day[index]) > int(list_day[index - 1]):
        .........больше

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question