informatica:linux:selenium
                Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| informatica:linux:selenium [2019/10/17 11:42] – jose | informatica:linux:selenium [2022/12/27 09:08] (current) – jose | ||
|---|---|---|---|
| Line 319: | Line 319: | ||
| ====== Padres e hijos ====== | ====== Padres e hijos ====== | ||
| + | |||
| Tenemos el siguiente código: | Tenemos el siguiente código: | ||
| < | < | ||
| Line 356: | Line 357: | ||
| {{: | {{: | ||
| - | Queremos | + | Queremos | 
| {{: | {{: | ||
| Line 375: | Line 376: | ||
| </ | </ | ||
| + | Si a partir de un elemento queremos seleccionar el padre:\\ | ||
| + | Seleccionamos el elemento: | ||
| + | xpath='// | ||
| + | obj = driver.find_element_by_xpath(xpath) | ||
| + | Y a partir de ese elemento el padre: | ||
| + | padre=obj.find_element_by_xpath(" | ||
| + | ====== Grabar el contenido de la web en un archivo ====== | ||
| + | |||
| + | ===== Texto ===== | ||
| + | |||
| + | |||
| + | https:// | ||
| + | |||
| + | En mi caso fue muy útil porque no fui capaz, ni con chrome ni con firefox, de obtener el xpath de un popup que al hacer click en cualquier parte se cerraba. | ||
| + | |||
| + | < | ||
| + | html = driver.execute_script(" | ||
| + | with open(" | ||
| + | f.write(html) | ||
| + | </ | ||
| + | |||
| + | ===== Captura de pantalla ===== | ||
| + | |||
| + | < | ||
| + | fichero = f" | ||
| + | driver.set_window_size(1080, | ||
| + | driver.save_screenshot(" | ||
| + | driver.save_screenshot(" | ||
| + | </ | ||
informatica/linux/selenium.1571312564.txt.gz · Last modified:  by jose
                
                