informatica:linux:selenium
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
informatica:linux:selenium [2019/09/24 07:20] – [Python firefox headless local] javi | informatica:linux:selenium [2019/10/17 11:42] – jose | ||
---|---|---|---|
Line 316: | Line 316: | ||
o.click() | o.click() | ||
</ | </ | ||
+ | |||
+ | |||
+ | ====== Padres e hijos ====== | ||
+ | Tenemos el siguiente código: | ||
+ | < | ||
+ | <div class=" | ||
+ | <div style=" | ||
+ | <div style=" | ||
+ | < | ||
+ | <div class=" | ||
+ | <div tabindex=" | ||
+ | <div class=" | ||
+ | <input name=" | ||
+ | <label class=" | ||
+ | </ | ||
+ | </ | ||
+ | <div tabindex=" | ||
+ | <div class=" | ||
+ | <input name=" | ||
+ | <label class=" | ||
+ | </ | ||
+ | </ | ||
+ | <div tabindex=" | ||
+ | <div class=" | ||
+ | <input name=" | ||
+ | <label class=" | ||
+ | </ | ||
+ | </ | ||
+ | <div tabindex=" | ||
+ | <div class=" | ||
+ | <input name=" | ||
+ | <label class=" | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | {{: | ||
+ | |||
+ | Queremos seleccionar input, la caja verde, pero dentro del div que tiene lel texto en title que es la caja padre en rojo | ||
+ | {{: | ||
+ | |||
+ | Primero seleccionamos el bloque padre, buscando por div y title que queramos: | ||
+ | < | ||
+ | menu_click=' | ||
+ | menu_click=' | ||
+ | menu_click=' | ||
+ | |||
+ | xpath='// | ||
+ | padre = driver.find_element_by_xpath(xpath) | ||
+ | </ | ||
+ | Ahora dentro de esa caja, selecctionamos el input para hacer click | ||
+ | < | ||
+ | xpath2=' | ||
+ | hijo = padre.find_element_by_xpath(xpath2) | ||
+ | hijo.click() | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ |
informatica/linux/selenium.txt · Last modified: 2022/12/27 09:08 by jose