Good day to all who read! I am a beginner autotester, please help with the following problem:

There is the following function:

def check_and_select_row (cls, grid, number, date): query = sql_query('''select [name] from [ref].[Departments]''') main_grid = Driver.get().find_elements_by_xpath( '//*[@id="invoiceJournalGrid"]/div[@class="k-grid-content k-auto-scrollable"]/table//tbody/tr') x = 1 y = 0 number = 0 date = 0 for status_check in main_grid: while y < len(query): if (cls.get_grid_values('Status', x, grid, mode='get_value') != 'Изъята' and cls.get_grid_values( 'DestDepartment', x, grid, mode='get_value') not in query[y]): cls.get_grid_values('DestDepartment', x, grid, mode='click') y += 1 number = cls.get_grid_values('OutgoingNumber', x, grid, mode='get_value') date = cls.get_grid_values('DocDate', x, grid, mode='get_value') else: y = 0 x += 1 return number, date 

The values ​​of the selected column are written to the variable number and date, the column is selected according to the conditions above.

Further, I need to use these values ​​in function 2:

 def check_expedition_report(cls, number, date): check_status = 0 check_department = 0 for el in Driver.get().find_elements_by_xpath('//div[@class="textLayer"]/*'): if number in el.text: check_status = 1 for el in Driver.get().find_elements_by_xpath('//div[@class="textLayer"]/*'): if date in el.text: check_department = 1 

where I check the report for the presence of variable values ​​extracted from function 1

The question is how to fix the code so that it works? Thank!

  • number, date = check_and_select_row(...) , check_expedition_report(cls, number, date) - Mikhail Murugov

1 answer 1

The check_and_select_row function returns 2 values. You can save these 2 values ​​to separate variables. Syntax:

 number, date = check_and_select_row(...) 

Further, these variables can be passed to the following function.

 check_expedition_report(cls, number, date) 

If you want the result from the first function to be immediately passed as an argument to the second, then

 check_expedition_report(cls, *check_and_select_row(...)) 
  • Thank you so much! - Alexey Tinkov
  • @ AlekseyTinkov On StackOverflow there is an opportunity to mark the correct answer, which helped, by ticking :) - Mikhail Murugov