I am writing a python script that uses requests module to download the latest release of geckodriver.exe for windows 64-bit, I added a few functions to make the download slightly more dynamic by identifying the OS type and the system architecture, and after downloaded unzip the package into the defined path I specified. The current … Continue reading [python]Download geckodriver for windows
This exercise will present a popup dialogue asking for your credential (which is admin, admin as shown in the exercise). This popup is not an alert nor an iframe, the only way is to include the username and password with the address to get through it with selenium. This is the original state after the … Continue reading [selenium] Handling authentication popup
Selenium works on web elements, so any browser's function selenium cannot automate. On this exercise, right click within the dotted box area will trigger a JS alert which says "You selected a context menu". To simulate right click with Selenium: First find the element of the dotted box, then use ActionChains to move to the … Continue reading [selenium] Simulate right click.
Selenium is about finding the elements to do action upon, the dropdown box exercise can be found here. From the web developer tool of your selected browser find the element of option1 and option2 and copy their xpaths, xpath is the most accurate for selenium to act upon, my preference is always xpath then next … Continue reading [selenium] Dropdown box selection
Selenium is a great web app automation tool which have several variants, I am using python to implement selenium on this https://the-internet.herokuapp.com/drag_and_drop, Selenium has an ActionChain that can do drag and drop, but this is not working in HTML5, the solution in another language (perhaps is ruby?) can be found here. I have converted the … Continue reading [selenium] Solution to HTML5 drag and drop with python
Webdriver I am using firefox hence I am downloading geckodriver to work with selenium. To set up the webdriver in the code do this: from selenium import webdriver driver_path = r"E:\webdriver\firefox\geckodriver.exe" driver = webdriver.Firefox(executable_path=driver_path) Install extension To install an extension to the webdriver for each instance do this: buster = r"E:\webdriver\firefox\buster_captcha_solver_for_humans-1.0.1-an+fx.xpi" driver.install_addon(buster, temporary=True) On every … Continue reading [python] Adding extension to geckodriver with selenium
This is an aggregation on how to use SQLAlchemy to create a database, table and insert data into the created table. Refer to this tutorial on how to use SQLAlchemy. from sqlalchemy_utils import database_exists, create_database from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker url = "mysql+pymysql://username:password@database_address/database_name" # Create … Continue reading [python]SQLAlchemy usage example
I remember I did not need to define the varchar length, however I encountered this error: sqlalchemy.exc.CompileError: (in table 'test_table', column 'name'): VARCHAR requires a length on dialect mysql So I would need to define the length of varchar with the String object from SqlAlchemy. meta = MetaData() """ Define the table. The below is … Continue reading [python]VARCHAR requires a length on dialect mysql with sqlalchemy
This is an example of using SQLAlchemy module to create database if it does not exist otherwise connect to the requested database. from sqlalchemy import create_engine from sqlalchemy_utils import database_exists, create_database from getpass import getpass """ database url is dialect+driver://username:password@db_address/db_name To connect to mysql/mariadb, pymysql module is required to install. The purpose of using SqlAlchemy … Continue reading [python]Create database if not exists with sqlalchemy
ord function is to convert a character to its equivalent integer representation. chr function is to convert the integer to its character representation. random.choice() method randomly picks a character from a series of characters to form a string of N length, this is the key for encryption and decryption. A message is taken from user's … Continue reading [python]Hand made cryptography with XOR method.