informatica:linux:selenium
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
informatica:linux:selenium [2019/10/17 11:46] – jose | informatica:linux:selenium [2020/05/08 09:17] – [Padres e hijos] javi | ||
---|---|---|---|
Line 319: | Line 319: | ||
====== Padres e hijos ====== | ====== Padres e hijos ====== | ||
+ | |||
Tenemos el siguiente código: | Tenemos el siguiente código: | ||
< | < | ||
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 ====== | ||
+ | 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) | ||
+ | </ |
informatica/linux/selenium.txt · Last modified: 2022/12/27 09:08 by jose