@@ -173,6 +173,8 @@ def create_database(
173173
174174 create_button = driver .find_element (By .ID , "create-btn" )
175175 create_button .click ()
176+ # Without this we might close the driver before the database is created.
177+ time .sleep (5 )
176178
177179
178180def get_database_details (
@@ -186,36 +188,30 @@ def get_database_details(
186188 driver .get (target_manager_url )
187189 ten_second_wait = WebDriverWait (driver , 10 )
188190
189- # This is a hack.
190- #
191- # Not all items are shown on the first page and we do not yet support going
192- # through pages.
193- #
194- # In our use cases so far we always want the latest databases.
195- #
196- #
197- # Therefore we sort by last modified date.
198- time .sleep (2 )
199- date_modified_element = driver .find_element (
200- By .ID ,
201- "sort-by-last-modified-date" ,
202- )
203- date_modified_element .click ()
204- time .sleep (10 )
205- date_modified_element .click ()
206-
207- time .sleep (2 )
208- database_name_xpath = "//span[text()='" + database_name + "']"
209-
210191 ten_second_wait .until (
211192 expected_conditions .presence_of_element_located (
212- (By .XPATH , database_name_xpath ),
193+ (By .ID , "table_search" ),
213194 ),
214195 )
215196
197+ search_input_element = driver .find_element (By .ID , "table_search" )
198+ original_first_database_cell_element = ten_second_wait .until (
199+ expected_conditions .element_to_be_clickable (
200+ (By .ID , "table_row_0_project_name" ),
201+ ),
202+ )
203+ search_input_element .send_keys (database_name )
204+ search_input_element .send_keys (Keys .RETURN )
205+ # The search has competed when the original first database cell element is
206+ # "stale".
207+ ten_second_wait .until (
208+ expected_conditions .staleness_of (original_first_database_cell_element ),
209+ )
210+
211+ # We assume that searching for the database name will return one result.
216212 database_cell_element = ten_second_wait .until (
217213 expected_conditions .element_to_be_clickable (
218- (By .XPATH , database_name_xpath ),
214+ (By .ID , "table_row_0_project_name" ),
219215 ),
220216 )
221217
0 commit comments