Problematic code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export async function enter_Search_Result(query) { | |
let openReportTimeout = 300000; | |
let reportSearchTitle = ""; | |
try { | |
let firstResultXpath = Return_First_Element_Xpath("//span[contains(text(),'"+query+"')]"); | |
if (!Wait_For_Selector(firstResultXpath)) { | |
console_log("enter_Search_Result_00: Failed to find: " + firstResultXpath + " --------"); | |
} | |
sleep(1); | |
start = Date.now(); | |
//enter Search | |
await Promise.all([ | |
global.page.waitForNavigation({ | |
timeout: openReportTimeout, | |
waitUntil: 'networkidle', | |
}), | |
global.page.locator(firstResultXpath).click(), | |
]); | |
//await Wait_And_Click("//div[@class='ag-center-cols-container']/div", "Enter Search report", true); | |
console_log("enter_Search_Result_01: Entering report --------"); | |
screenshot("Loaded_Results_1"); | |
} catch (err) { | |
screenshot("ERROR_Loaded_Results"); | |
throw new Error("enter_Search_Result: ERROR " + err); | |
} | |
} | |
export async function Wait_For_Selector(elementSelector, elementTimeout = 60000) { | |
try { | |
let selectorExists = global.page.waitForSelector(elementSelector, {timeout: elementTimeout}); | |
if (selectorExists != null) { | |
console_log("Wait_For_Selector: Found selector " + elementSelector); | |
return true; | |
} | |
else { | |
console_log("Wait_For_Selector: Selector wasn't found " + elementSelector); | |
return false; | |
} | |
} catch (err) { | |
console_log("Wait_For_Selector: Selector wasn't found " + elementSelector + ". Error: "+ err); | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment