Thursday, November 14, 2019

Finding elements with Python Selenium

HTML:
<button type="submit" class="button search-button" onclick="">Search</button>

Using XPATH:
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.XPATH, '//button[@type="submit" and @class="button search-button" and text()="Search"]'))).click()
Using CSS_SELECTOR:
WebDriverWait(driver,10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, 'button[type="submit"][class="button search-button"]'))).click()

Sunday, November 10, 2019

How to convert your Python script into an executable file (from .py to .exe)

1. pip install pyinstaller
2. Go to the folder which contains your python script (.py)... e.g. C:\user\Tim\
3. pyinstaller.exe --onefile --icon=sun_icon.ico python_script.py --noconsole

  • icon (*.ico) file should be in the same folder as your python script
  • --noconsole will eliminate the black screen that appears on running the exe file
  • "--hidden-import=modulename" will ensure that python also includes modules (that tend to be hidden) into the exe file (not guaranteed to work)
  • "-v" for verbose/detailed log

4. Go into the "dist" subfolder i.e. C:\user\Tim\dist\
5. Run the .exe file
Note: If the file appears to be stuck in a black screen, ensure any related images are also copied to the "dist" folder where the .exe file is located.

Tuesday, November 5, 2019

How to Install an Older Version of Python

1. Go to https://www.python.org/downloads/

2. Open every link (for that Python's version you are interested in) in a different tab. For example, if you are looking to install Python 3.6, then open the link that to Python 3.6.9, Python 3.6.8, etc. Start with the latest version (Python 3.6.9) and move backwards, because the latest version will have the latest security updates.

3. Within each tab, look for the executable installer that fits your requirements. This is an .exe file that will run easily once you download it to your PC. Pick the file that meets your PC requirements. For example, if your operating system uses Windows 64 bit, then download "Windows x86-64 executable installer"

4. Double click the downloaded executable file (e.g. python-3.6.8-amd64.exe) to install it on your PC.

5. Start your favorite IDE e.g. PyCharm

6. Create a new project and ensure you specify the absolute path for your project interpreter. Example:

  • Project Interpreter: Base interpreter: C:\Users\Tim\AppData\Local\Programs\Python\Python36\python.exe
  • Hit the Create button, and you're ready to go


Monday, October 14, 2019

How to check your DBKL summons online

To check and pay your DBKL summons online, there are several ways depending on the information you have with you:


If you have VEHICLE NUMBER and the legal owner's NRIC
Here is a quick link to check:
https://appsys.dbkl.gov.my/ezbill/index.asp

If you have the NOTICE NUMBER
You can check and pay your summons online at MyEG's website. The notice number is located at the top right corner of the DBKL summons, and looks like this: AAA4367xxx.

Do note that there is an e-services charge of MYR2.00 and a sales and services tax of 6% when using the MyEG portal.

1. Go to https://www.myeg.com.my/ and log in

2. Click on the "Dewan Bandaraya Kuala Lumpur" logo

3. Select "Check/Pay Offence(s)/Compound(s) or Semak/Bayar Kesalahan/Kompaun"

4. Under the Select Query Option, pick "Notice No.", then enter the notice number found on your summons slip (example: AAA4367xxx) and click Proceed.



5. As shown above, you'll see your outstanding summons, and have the option to pay online, using credit card or online banking transfer.





Popular Posts