following code working but i need to combine two arrays and show it as a plain text line…
- User
following code working but i need to combine two arrays and show it as a plain text line by line at consolo log const button1 = Array.from(document.querySelectorAll('button.MuiButton-root')).find(btn => btn.textContent.trim() === '1'); const button2 = Array.from(document.querySelectorAll('button.MuiButton-root')).find(btn => btn.textContent.trim() === '2');
setTimeout(() => { button1.click(); }, 1000);
setTimeout(() => { const symbols1 = Array.from(document.querySelectorAll('tbody.ant-table-tbody .symbol-name')).map(el => el.textContent); console.log(symbols1); }, 2000); // Wait for 2 seconds to allow for any loading
setTimeout(() => { button2.click(); }, 3000); // Wait for 3 seconds total before clicking the second button
setTimeout(() => { const symbols2 = Array.from(document.querySelectorAll('tbody.ant-table-tbody .symbol-name')).map(el => el.textContent); console.log(symbols2); }, 7000); // Wait for 4 seconds total for the second button's data to load
- Assistant
To combine the two arrays (
symbols1andsymbols2) and print each element as plain text line by line in the console, you can use theconcatmethod andforEachto log each element individually. Here's how you can modify your code to achieve this:const button1 = Array.from(document.querySelectorAll('button.MuiButton-root')).find(btn => btn.textContent.trim() === '1'); const button2 = Array.from(document.querySelectorAll('button.MuiButton-root')).find(btn => btn.textContent.trim() === '2'); let symbols1 = []; let symbols2 = []; setTimeout(() => { button1.click(); }, 1000); setTimeout(() => { symbols1 = Array.from(document.querySelectorAll('tbody.ant-table-tbody .symbol-name')).map(el => el.textContent); console.log('Symbols from first button:'); console.log(symbols1); }, 2000); // Wait for 2 seconds to allow for any loading setTimeout(() => { button2.click(); }, 3000); // Wait for 3 seconds total before clicking the second button setTimeout(() => { symbols2 = Array.from(document.querySelectorAll('tbody.ant-table-tbody .symbol-name')).map(el => el.textContent); console.log('Symbols from second button:'); console.log(symbols2); // Combine the arrays and print them line by line const combinedSymbols = symbols1.concat(symbols2); console.log('Combined symbols:'); combinedSymbols.forEach(symbol => console.log(symbol)); }, 7000); // Wait for 4 seconds total for the second button's data to load