divendres, 21 d’abril del 2023

clic a un conjunto de botones a través de su xpath - DevTools Console

const elements = document.evaluate('//a[@class="answer flex items-center text-xl text-aac-orange hover:no-underline"]', document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);


for (let i = 0; i < elements.snapshotLength; i++) {

  const element = elements.snapshotItem(i);

  element.click();

}


dijous, 6 d’abril del 2023

Open the Device Manager from the Run dialog box (Win+R)

 You can open the Device Manager from the Run dialog box (Win+R) by following these steps:

Press Win+R to open the Run dialog box.

Type "devmgmt.msc" (without the quotes) in the "Open" field and press Enter or click OK.

This will open the Device Manager window where you can view and manage the devices installed on your computer.

dimarts, 4 d’abril del 2023

List of available cameras on computer

Get-CimInstance -ClassName Win32_PnpEntity | Where-Object {$_.Caption -like '*camera*'} | Select-Object Name, Caption

 

PowerTip: Use PowerShell to Discover Laptop Webcam

Doctor Scripto

Summary: Use Windows PowerShell to discover a webcam attached to your laptop.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find a webcam or camera that is attached to my laptop?

Hey, Scripting Guy! Answer Use the Get-CimInstance or the Get-WmiObject cmdlet, examine the Win32_PnpEntity WMI class,
          and look for something that matches camera in the caption.

By using Get-CimInstance in Windows PowerShell 3.0 or later:

Get-CimInstance Win32_PnPEntity | where caption -match 'camera'

By using Get-WmiObject in Windows PowerShell 2.0:

Get-WmiObject Win32_PnPEntity | where {$_.caption -match 'camera'}

Note  Not all webcams populate exactly the same way, so it may take a bit of searching
to find the right string.

dimecres, 22 de febrer del 2023

Marcar checkbox: tots i algun d'específic

 A la consola del DevTools, marcarem tots els checkbox de la pàgina web oberta entrant:


document.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) {

  checkbox.checked = true;

});

si el que volem és seleccionar els checkbox que són dins d'un xpath concret, obtenim l'xpath a partir de l'eina Selector

//*[@id="form_llistar"]/table/tbody/tr[1]/td[1]/table/tbody/tr[6]


... i a partir de l'xpath anterior entrem a la consola:

document.querySelectorAll('#form_llistar table tbody tr:nth-child(6) input[type="checkbox"]').forEach(function(checkbox) {

  checkbox.checked = true;

});

En el cas que vulguem marcar amb dos condicions, que estigui en tr(5) 

#form_llistar table tbody tr:nth-child(6) td:nth-child(4) input[type="checkbox"] + td:nth-child(5):not(:empty):first-child:not(:last-child):not([colspan])


dimecres, 8 de febrer del 2023

Chropath and Xpath

 The syntax to get only div you are interested in


//*[@id="__next"]/div[1]/div/main/div[1]/div/div/div/div[position()>=12 and position()<=22]/div


To get the list of text, we will inspect the first element, a new DevTools Window will appear. We put on il just previous to the selected div and Expand recursively

Then, in Console window, the write

console.log($0.textContent)