Functions/Get-Puppeteer_RetrieveTextFromSelector.Tests.ps1
describe "BitTitan.Runbooks.UIAutomation/Get-Puppeteer_RetrieveTextFromSelector" -Tags "module", "unit" { # Import the function to test . "$($PSScriptRoot)\Get-Puppeteer_RetrieveTextFromSelector.ps1" it "returns the code for retrieving text from a selector" { # Call the function $output = Get-Puppeteer_RetrieveTextFromSelector -SelectorName "#selector" -VariableName "answer" # Verify the output $output | Should Be @" selector = '#selector' await page.waitForSelector(selector); answer = await page.evaluate(selector => { const anchors = Array.from(document.querySelectorAll(selector)); return anchors.map(anchor => { return anchor.textContent; }); }, selector); "@ } } |