Fixed a bug with the show rows in gkwp.
This commit is contained in:
parent
10277adbd8
commit
5d5d96df9e
|
|
@ -476,74 +476,123 @@
|
|||
// First check if we're already at 500 rows
|
||||
const currentInfo = getCurrentPageInfo();
|
||||
if (currentInfo && currentInfo.perPage === 500) {
|
||||
console.log('Already at 500 rows per page');
|
||||
console.log('Already at 500 rows');
|
||||
return true;
|
||||
}
|
||||
|
||||
// First find the dropdown container
|
||||
// Find the dropdown button using multiple selectors
|
||||
const dropdownSelectors = [
|
||||
'material-dropdown-select[aria-label="Show rows"]',
|
||||
'material-dropdown-select[aria-label="Show rows"] material-dropdown-select',
|
||||
'[aria-label="Show rows: 100 selected."]',
|
||||
'.dropdown-label-container'
|
||||
'.dropdown-label-container',
|
||||
'div[aria-label^="Show rows:"]',
|
||||
'material-dropdown-select[role="listbox"]'
|
||||
];
|
||||
|
||||
let dropdownButton = null;
|
||||
for (const selector of dropdownSelectors) {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
console.log(`Found dropdown using selector: ${selector}`);
|
||||
const elements = document.querySelectorAll(selector);
|
||||
for (const element of elements) {
|
||||
if (element.offsetParent !== null) {
|
||||
console.log(`Found visible dropdown using selector: ${selector}`);
|
||||
dropdownButton = element;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dropdownButton) break;
|
||||
}
|
||||
|
||||
if (!dropdownButton) {
|
||||
console.log('Could not find rows dropdown button');
|
||||
console.log('Could not find dropdown button');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Click the dropdown to open it
|
||||
console.log('Clicking dropdown button...');
|
||||
dropdownButton.click();
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
|
||||
// Look for the 500 option
|
||||
const optionSelectors = [
|
||||
'material-select-dropdown-item',
|
||||
'[role="option"]'
|
||||
// Wait for the popup to be visible
|
||||
const popup = document.querySelector('.material-dropdown-select-popup.visible');
|
||||
if (!popup) {
|
||||
console.log('Dropdown popup not visible after click');
|
||||
return false;
|
||||
}
|
||||
|
||||
// Find the 500 option using multiple strategies
|
||||
const option500Selectors = [
|
||||
'material-select-dropdown-item[role="option"] .label',
|
||||
'.item[role="option"] .label',
|
||||
'material-select-dropdown-item .label'
|
||||
];
|
||||
|
||||
let found500Option = null;
|
||||
for (const selector of optionSelectors) {
|
||||
for (const selector of option500Selectors) {
|
||||
const options = Array.from(document.querySelectorAll(selector));
|
||||
for (const option of options) {
|
||||
const text = option.textContent.trim();
|
||||
if (text === '500') {
|
||||
found500Option = option;
|
||||
console.log(`Found 500 option using selector: ${selector}`);
|
||||
if (option.textContent.trim() === '500') {
|
||||
// Get the parent option element
|
||||
found500Option = option.closest('[role="option"]');
|
||||
if (found500Option?.offsetParent !== null) {
|
||||
console.log(`Found visible 500 option using selector: ${selector}`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (found500Option) break;
|
||||
}
|
||||
|
||||
if (found500Option) {
|
||||
if (!found500Option) {
|
||||
// Try finding by aria-label as fallback
|
||||
const ariaOptions = document.querySelectorAll('[aria-label*="500"]');
|
||||
for (const option of ariaOptions) {
|
||||
if (option.offsetParent !== null) {
|
||||
found500Option = option;
|
||||
console.log('Found 500 option using aria-label');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found500Option) {
|
||||
console.log('Could not find 500 option in dropdown');
|
||||
// Close the dropdown since we couldn't find the option
|
||||
document.body.click();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Click the 500 option
|
||||
console.log('Clicking 500 option...');
|
||||
found500Option.click();
|
||||
|
||||
// Wait for the page to update
|
||||
await new Promise(resolve => setTimeout(resolve, 3000));
|
||||
// Wait for the change to take effect
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
|
||||
// Verify the change by checking page info
|
||||
// Verify the change
|
||||
const updatedInfo = getCurrentPageInfo();
|
||||
if (updatedInfo && updatedInfo.perPage === 500) {
|
||||
console.log('Successfully changed to 500 rows');
|
||||
return true;
|
||||
}
|
||||
|
||||
// Additional verification using pagination text
|
||||
const paginationText = await getPaginationText();
|
||||
if (paginationText && typeof paginationText === 'string') {
|
||||
console.log('Current pagination text:', paginationText);
|
||||
|
||||
// Check if we're seeing more than 100 rows
|
||||
const match = paginationText.match(/(\d+)\s*-\s*(\d+)/);
|
||||
if (match) {
|
||||
const [, start, end] = match;
|
||||
if (parseInt(end) - parseInt(start) > 99) {
|
||||
console.log('Pagination shows more than 100 rows, considering success');
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Could not find or click 500 option');
|
||||
console.log('Could not verify row count change');
|
||||
return false;
|
||||
} catch (error) {
|
||||
console.error('Error setting rows to 500:', error);
|
||||
|
|
|
|||
Loading…
Reference in a new issue