Skip to content

Commit

Permalink
Release build 5.19.0 [ci release]
Browse files Browse the repository at this point in the history
  • Loading branch information
shakyShane authored and github-actions[bot] committed Jun 4, 2024
1 parent 1f563c0 commit ba2ad0c
Show file tree
Hide file tree
Showing 12 changed files with 318 additions and 47 deletions.
34 changes: 25 additions & 9 deletions Sources/ContentScopeScripts/dist/contentScopeIsolated.js
Original file line number Diff line number Diff line change
Expand Up @@ -10447,7 +10447,16 @@
const profilesElementList = getElements(root, action.selector) ?? [];

if (profilesElementList.length === 0) {
return { error: 'no root elements found for ' + action.selector }
if (!action.noResultsSelector) {
return { error: 'no root elements found for ' + action.selector }
}

// Look for the Results Not Found element
const foundNoResultsElement = getElement(root, action.noResultsSelector);

if (!foundNoResultsElement) {
return { error: 'no results found for ' + action.selector + ' or the no results selector ' + action.noResultsSelector }
}
}

return {
Expand Down Expand Up @@ -11142,18 +11151,25 @@
// there can be multiple elements provided by the action
for (const element of action.elements) {
const rootElement = selectRootElement(element, userData, root);
const elem = getElement(rootElement, element.selector);
const elements = getElements(rootElement, element.selector);

if (!elem) {
if (!elements?.length) {
return new ErrorResponse({ actionID: action.id, message: `could not find element to click with selector '${element.selector}'!` })
}
if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })

const loopLength = element.multiple && element.multiple === true ? elements.length : 1;

for (let i = 0; i < loopLength; i++) {
const elem = elements[i];

if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}

Expand Down
34 changes: 25 additions & 9 deletions build/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -20376,7 +20376,16 @@
const profilesElementList = getElements(root, action.selector) ?? [];

if (profilesElementList.length === 0) {
return { error: 'no root elements found for ' + action.selector }
if (!action.noResultsSelector) {
return { error: 'no root elements found for ' + action.selector }
}

// Look for the Results Not Found element
const foundNoResultsElement = getElement(root, action.noResultsSelector);

if (!foundNoResultsElement) {
return { error: 'no results found for ' + action.selector + ' or the no results selector ' + action.noResultsSelector }
}
}

return {
Expand Down Expand Up @@ -21071,18 +21080,25 @@
// there can be multiple elements provided by the action
for (const element of action.elements) {
const rootElement = selectRootElement(element, userData, root);
const elem = getElement(rootElement, element.selector);
const elements = getElements(rootElement, element.selector);

if (!elem) {
if (!elements?.length) {
return new ErrorResponse({ actionID: action.id, message: `could not find element to click with selector '${element.selector}'!` })
}
if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })

const loopLength = element.multiple && element.multiple === true ? elements.length : 1;

for (let i = 0; i < loopLength; i++) {
const elem = elements[i];

if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}

Expand Down
34 changes: 25 additions & 9 deletions build/integration/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -20376,7 +20376,16 @@
const profilesElementList = getElements(root, action.selector) ?? [];

if (profilesElementList.length === 0) {
return { error: 'no root elements found for ' + action.selector }
if (!action.noResultsSelector) {
return { error: 'no root elements found for ' + action.selector }
}

// Look for the Results Not Found element
const foundNoResultsElement = getElement(root, action.noResultsSelector);

if (!foundNoResultsElement) {
return { error: 'no results found for ' + action.selector + ' or the no results selector ' + action.noResultsSelector }
}
}

return {
Expand Down Expand Up @@ -21071,18 +21080,25 @@
// there can be multiple elements provided by the action
for (const element of action.elements) {
const rootElement = selectRootElement(element, userData, root);
const elem = getElement(rootElement, element.selector);
const elements = getElements(rootElement, element.selector);

if (!elem) {
if (!elements?.length) {
return new ErrorResponse({ actionID: action.id, message: `could not find element to click with selector '${element.selector}'!` })
}
if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })

const loopLength = element.multiple && element.multiple === true ? elements.length : 1;

for (let i = 0; i < loopLength; i++) {
const elem = elements[i];

if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}

Expand Down
34 changes: 25 additions & 9 deletions build/windows/contentScope.js
Original file line number Diff line number Diff line change
Expand Up @@ -15686,7 +15686,16 @@
const profilesElementList = getElements(root, action.selector) ?? [];

if (profilesElementList.length === 0) {
return { error: 'no root elements found for ' + action.selector }
if (!action.noResultsSelector) {
return { error: 'no root elements found for ' + action.selector }
}

// Look for the Results Not Found element
const foundNoResultsElement = getElement(root, action.noResultsSelector);

if (!foundNoResultsElement) {
return { error: 'no results found for ' + action.selector + ' or the no results selector ' + action.noResultsSelector }
}
}

return {
Expand Down Expand Up @@ -16381,18 +16390,25 @@
// there can be multiple elements provided by the action
for (const element of action.elements) {
const rootElement = selectRootElement(element, userData, root);
const elem = getElement(rootElement, element.selector);
const elements = getElements(rootElement, element.selector);

if (!elem) {
if (!elements?.length) {
return new ErrorResponse({ actionID: action.id, message: `could not find element to click with selector '${element.selector}'!` })
}
if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })

const loopLength = element.multiple && element.multiple === true ? elements.length : 1;

for (let i = 0; i < loopLength; i++) {
const elem = elements[i];

if ('disabled' in elem) {
if (elem.disabled) {
return new ErrorResponse({ actionID: action.id, message: `could not click disabled element ${element.selector}'!` })
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}
if ('click' in elem && typeof elem.click === 'function') {
elem.click();
}
}

Expand Down
31 changes: 30 additions & 1 deletion integration-test/playwright/broker-protection.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,25 @@ test.describe('Broker Protection communications', () => {
}])
dbp.responseContainsMetadata(response[0].payload.params.result.success.meta)
})

test('returns an empty array when no profile selector matches but the no results selector is present', async ({ page }, workerInfo) => {
const dbp = BrokerProtectionPage.create(page, workerInfo)
await dbp.enabled()
await dbp.navigatesTo('results-not-found.html')
await dbp.receivesAction('results-not-found-valid.json')
const response = await dbp.waitForMessage('actionCompleted')
dbp.isSuccessMessage(response)
dbp.isExtractMatch(response[0].payload.params.result.success.response, [])
})

test('returns an error when no profile selector matches and the no results selector is not present', async ({ page }, workerInfo) => {
const dbp = BrokerProtectionPage.create(page, workerInfo)
await dbp.enabled()
await dbp.navigatesTo('results.html')
await dbp.receivesAction('results-not-found-invalid.json')
const response = await dbp.waitForMessage('actionCompleted')
dbp.isErrorMessage(response)
})
})
test.describe('Executes action and sends success message', () => {
test('buildUrl', async ({ page }, workerInfo) => {
Expand Down Expand Up @@ -381,6 +400,17 @@ test.describe('Broker Protection communications', () => {
await page.waitForURL(url => url.hash === '#2', { timeout: 2000 })
})

test('click multiple targets', async ({ page }, workerInfo) => {
const dbp = BrokerProtectionPage.create(page, workerInfo)
await dbp.enabled()
await dbp.navigatesTo('click-multiple.html')
await dbp.receivesAction('click-multiple.json')
const response = await dbp.waitForMessage('actionCompleted')

dbp.isSuccessMessage(response)
await page.waitForURL(url => url.hash === '#1-2', { timeout: 2000 })
})

test('getCaptchaInfo', async ({ page }, workerInfo) => {
const dbp = BrokerProtectionPage.create(page, workerInfo)
await dbp.enabled()
Expand Down Expand Up @@ -485,7 +515,6 @@ test.describe('Broker Protection communications', () => {
}
}
})

await page.getByRole('heading', { name: 'Retry' }).waitFor({ timeout: 5000 })

const response = await dbp.waitForMessage('actionCompleted')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"state": {
"action": {
"actionType": "click",
"id": "1",
"elements": [
{
"type": "button",
"selector": ".view-more",
"multiple": true
}
]
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"state": {
"action": {
"actionType": "extract",
"selector": ".search-item-invalid",
"noResultsSelector": ".none",
"retry": {
"environment": "web",
"interval": { "ms": 1000 },
"maxAttempts": 1
},
"profile": {
"name": {
"selector": "h4"
},
"alternativeNamesList": {
"selector": ".//div[@class='col-sm-24 col-md-16 name']//li",
"findElements": true
},
"age": {
"selector": ".age"
},
"addressCityStateList": {
"selector": ".//div[@class='col-sm-24 col-md-8 location']//li",
"findElements": true
},
"relativesList": {
"selector": ".//div[@class='col-sm-24 col-md-8 relatives']//li",
"beforeText": ","
},
"profileUrl": {
"selector": "a"
}
}
},
"data": {
"userProfile": {
"firstName": "John",
"lastName": "Smith",
"age": "37",
"addresses": [
{
"addressLine1": "123 Fake St",
"city": "Chicago",
"state": "IL",
"zip": "60602"
}
]
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"state": {
"action": {
"actionType": "extract",
"id": "efa321f2-f214-411f-a87b-bc42feff7931",
"selector": "[class^='ResultsTable__Record-sc']",
"noResultsSelector": "[class^=ResultNotFound__NoResults]",
"profile": {
"name": {
"selector": "[class^='ResultsTable__Name-sc']"
},
"age": {
"selector": "[class^='ResultsTable__Age-sc']"
},
"addressCityState": {
"selector": ".MuiGrid-item:nth-child(3) [class^='ResultsTable__AddressAndLocation-sc']",
"findElements": true
},
"relativesList": {
"selector": ".MuiGrid-item:nth-child(4) [class^='ResultsTable__AddressAndLocation-sc']",
"findElements": true
},
"profileUrl": {
"identifierType": "hash"
}
}
},
"data": {
"userProfile": {
"firstName": "John",
"lastName": "Smith",
"age": "37",
"addresses": [
{
"addressLine1": "123 Fake St",
"city": "Chicago",
"state": "IL",
"zip": "60602"
}
]
}
}
}
}

Loading

0 comments on commit ba2ad0c

Please sign in to comment.