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/23 19:29] – jose | informatica:linux:selenium [2019/10/17 11:42] – jose | ||
---|---|---|---|
Line 146: | Line 146: | ||
====== Python firefox headless local ====== | ====== Python firefox headless local ====== | ||
+ | |||
+ | ===== Sin profile ===== | ||
+ | |||
**IMPORTANTE**: | **IMPORTANTE**: | ||
Line 157: | Line 160: | ||
from selenium.webdriver import Firefox | from selenium.webdriver import Firefox | ||
- | | + | # Local headless |
- | options.add_argument(' | + | options = Options() |
- | | + | options.headless |
- | d.set_window_size(1920, 1080) | + | driver |
- | | + | </ |
+ | |||
+ | ===== Con profile ===== | ||
+ | |||
+ | < | ||
+ | from selenium.webdriver.firefox.options import Options | ||
+ | from selenium.webdriver import Firefox, FirefoxProfile | ||
+ | |||
+ | # Local headless | ||
+ | options = Options() | ||
+ | options.headless = True | ||
+ | driver = Firefox(firefox_profile = profile, options = options) | ||
</ | </ | ||
Line 302: | 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