├── README.md ├── ClassSelenium ├── main.py └── files_otros │ └── store_selernium.py ├── IniciarSelenium └── ejercio1.py └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # beat_data_selenium_xpath 2 | video tutorial youtube para iniciar con selenium usando XPATH 3 | -------------------------------------------------------------------------------- /ClassSelenium/main.py: -------------------------------------------------------------------------------- 1 | from files_otros.store_selernium import Store_Sele 2 | 3 | with Store_Sele() as bot: 4 | 5 | bot.get_url() 6 | bot.rellenar_form() -------------------------------------------------------------------------------- /IniciarSelenium/ejercio1.py: -------------------------------------------------------------------------------- 1 | import selenium 2 | import os 3 | import time 4 | from selenium import webdriver 5 | from selenium.webdriver.common.by import By 6 | 7 | #iniciar con el url 8 | url='http://demo-store.seleniumacademy.com' 9 | path_driver=os.chdir('D:\driver_sel') 10 | #objeto driver 11 | driver=webdriver.Chrome(executable_path='webdriver') 12 | #obtener un url con driver 13 | driver.maximize_window() 14 | driver.get(url) 15 | #obtner texto women 16 | texto_1=driver.find_element(By.XPATH,'//nav/ol/li/a[contains(text(),"Wo")]') 17 | #print(texto_1.text) 18 | 19 | 20 | #textos_2=driver.find_elements(By.XPATH,'//nav/ol/li/a') 21 | #for i in textos_2: 22 | # print(i.text) 23 | cuenta=driver.find_element(By.XPATH,'//span[contains(text(), "Account")]') 24 | cuenta.click() 25 | register=driver.find_element(By.XPATH, '//li/a[@title="Register"]') 26 | register.click() 27 | #rellenar formulario 28 | first_name=driver.find_element(By.XPATH,'//input[@id="firstname"]') 29 | first_name.send_keys('fernando') 30 | 31 | midle_name=driver.find_element(By.XPATH,'//input[@id="middlename"]') 32 | midle_name.send_keys('pullutasig') 33 | 34 | last_name=driver.find_element(By.XPATH,'//input[@id="lastname"]') 35 | last_name.send_keys('pullutasig') 36 | 37 | email=driver.find_element(By.XPATH,'//input[@id="email_address"]') 38 | email.send_keys('ejemplo@correo.com.ec') 39 | 40 | password=driver.find_element(By.XPATH,'//input[@id="password"]') 41 | password.send_keys('abc123') 42 | 43 | password_confir=driver.find_element(By.XPATH,'//input[@id="confirmation"]') 44 | password_confir.send_keys('abc123') 45 | 46 | check_input=driver.find_element(By.XPATH, '//input[@type="checkbox"]') 47 | check_input.click() 48 | 49 | registro=driver.find_element(By.XPATH,'//button[@title="Register"]') 50 | registro.click() 51 | 52 | time.sleep(10) -------------------------------------------------------------------------------- /ClassSelenium/files_otros/store_selernium.py: -------------------------------------------------------------------------------- 1 | import selenium 2 | import os 3 | import time 4 | from selenium import webdriver 5 | from selenium.webdriver.common.by import By 6 | 7 | URL='http://demo-store.seleniumacademy.com' 8 | 9 | class Store_Sele(webdriver.Chrome): 10 | def __init__(self, self_path='D:\driver_sel\webdriver', teardown=False): 11 | self.self_path=self_path 12 | self.teardown=teardown 13 | 14 | super(Store_Sele, self).__init__() 15 | self.maximize_window() 16 | 17 | def __exit__(self, exce_type, exc_val, exc_tb): 18 | if self.teardown: 19 | self.quit() 20 | 21 | #escriber metodos 22 | def get_url(self): 23 | self.get(URL) 24 | 25 | #rellenar formulario 26 | def rellenar_form(self): 27 | cuenta=self.find_element(By.XPATH,'//span[contains(text(), "Account")]') 28 | cuenta.click() 29 | register=self.find_element(By.XPATH, '//li/a[@title="Register"]') 30 | register.click() 31 | #rellenar formulario 32 | first_name=self.find_element(By.XPATH,'//input[@id="firstname"]') 33 | first_name.send_keys('fernando') 34 | 35 | midle_name=self.find_element(By.XPATH,'//input[@id="middlename"]') 36 | midle_name.send_keys('pullutasig') 37 | 38 | last_name=self.find_element(By.XPATH,'//input[@id="lastname"]') 39 | last_name.send_keys('pullutasig') 40 | 41 | email=self.find_element(By.XPATH,'//input[@id="email_address"]') 42 | email.send_keys('ejemplo@correo.com.ec') 43 | 44 | password=self.find_element(By.XPATH,'//input[@id="password"]') 45 | password.send_keys('abc123') 46 | 47 | password_confir=self.find_element(By.XPATH,'//input[@id="confirmation"]') 48 | password_confir.send_keys('abc123') 49 | 50 | check_input=self.find_element(By.XPATH, '//input[@type="checkbox"]') 51 | check_input.click() 52 | 53 | registro=self.find_element(By.XPATH,'//button[@title="Register"]') 54 | registro.click() 55 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Created by https://www.toptal.com/developers/gitignore/api/python 2 | # Edit at https://www.toptal.com/developers/gitignore?templates=python 3 | 4 | ### Python ### 5 | # Byte-compiled / optimized / DLL files 6 | __pycache__/ 7 | *.py[cod] 8 | *$py.class 9 | 10 | # C extensions 11 | *.so 12 | 13 | # Distribution / packaging 14 | .Python 15 | build/ 16 | develop-eggs/ 17 | dist/ 18 | downloads/ 19 | eggs/ 20 | .eggs/ 21 | lib/ 22 | lib64/ 23 | parts/ 24 | sdist/ 25 | var/ 26 | wheels/ 27 | share/python-wheels/ 28 | *.egg-info/ 29 | .installed.cfg 30 | *.egg 31 | MANIFEST 32 | 33 | # PyInstaller 34 | # Usually these files are written by a python script from a template 35 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 36 | *.manifest 37 | *.spec 38 | 39 | # Installer logs 40 | pip-log.txt 41 | pip-delete-this-directory.txt 42 | 43 | # Unit test / coverage reports 44 | htmlcov/ 45 | .tox/ 46 | .nox/ 47 | .coverage 48 | .coverage.* 49 | .cache 50 | nosetests.xml 51 | coverage.xml 52 | *.cover 53 | *.py,cover 54 | .hypothesis/ 55 | .pytest_cache/ 56 | cover/ 57 | 58 | # Translations 59 | *.mo 60 | *.pot 61 | 62 | # Django stuff: 63 | *.log 64 | local_settings.py 65 | db.sqlite3 66 | db.sqlite3-journal 67 | 68 | # Flask stuff: 69 | instance/ 70 | .webassets-cache 71 | 72 | # Scrapy stuff: 73 | .scrapy 74 | 75 | # Sphinx documentation 76 | docs/_build/ 77 | 78 | # PyBuilder 79 | .pybuilder/ 80 | target/ 81 | 82 | # Jupyter Notebook 83 | .ipynb_checkpoints 84 | 85 | # IPython 86 | profile_default/ 87 | ipython_config.py 88 | 89 | # pyenv 90 | # For a library or package, you might want to ignore these files since the code is 91 | # intended to run in multiple environments; otherwise, check them in: 92 | # .python-version 93 | 94 | # pipenv 95 | # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. 96 | # However, in case of collaboration, if having platform-specific dependencies or dependencies 97 | # having no cross-platform support, pipenv may install dependencies that don't work, or not 98 | # install all needed dependencies. 99 | #Pipfile.lock 100 | 101 | # poetry 102 | # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control. 103 | # This is especially recommended for binary packages to ensure reproducibility, and is more 104 | # commonly ignored for libraries. 105 | # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control 106 | #poetry.lock 107 | 108 | # pdm 109 | # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control. 110 | #pdm.lock 111 | # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it 112 | # in version control. 113 | # https://pdm.fming.dev/#use-with-ide 114 | .pdm.toml 115 | 116 | # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm 117 | __pypackages__/ 118 | 119 | # Celery stuff 120 | celerybeat-schedule 121 | celerybeat.pid 122 | 123 | # SageMath parsed files 124 | *.sage.py 125 | 126 | # Environments 127 | .env 128 | .venv 129 | env/ 130 | venv/ 131 | ENV/ 132 | env.bak/ 133 | venv.bak/ 134 | 135 | # Spyder project settings 136 | .spyderproject 137 | .spyproject 138 | 139 | # Rope project settings 140 | .ropeproject 141 | 142 | # mkdocs documentation 143 | /site 144 | 145 | # mypy 146 | .mypy_cache/ 147 | .dmypy.json 148 | dmypy.json 149 | 150 | # Pyre type checker 151 | .pyre/ 152 | 153 | # pytype static type analyzer 154 | .pytype/ 155 | 156 | # Cython debug symbols 157 | cython_debug/ 158 | 159 | # PyCharm 160 | # JetBrains specific template is maintained in a separate JetBrains.gitignore that can 161 | # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore 162 | # and can be added to the global gitignore or merged into this file. For a more nuclear 163 | # option (not recommended) you can uncomment the following to ignore the entire idea folder. 164 | #.idea/ 165 | 166 | ### Python Patch ### 167 | # Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration 168 | poetry.toml 169 | 170 | # ruff 171 | .ruff_cache/ 172 | 173 | # LSP config files 174 | pyrightconfig.json 175 | 176 | # End of https://www.toptal.com/developers/gitignore/api/python --------------------------------------------------------------------------------