Skip to main content

Posts

Showing posts from March, 2018

Python - Kivy and Selenium - Kite application automation code

from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput from kivy.uix.button import Button from kivy.core.window import Window from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.by import By import selenium.webdriver.support.ui as ui from selenium.webdriver.support.ui import WebDriverWait import selenium.webdriver.support.expected_conditions as EC import os import getpass import time import pymsgbox Window.size = ( 300 , 120 ) #PcName = getpass.getuser() class Kite ( GridLayout ): def __init__ ( self , ** kwargs ): super (Kite, self ).__init__(**kwargs) self .cols= 3 self .btn_buy = Button( text = "Buy" ) self .btn_buy.bind( on_press = self .buy_button_click)

Python - Kivy Sample Project

from kivy.app import App from kivy.uix.gridlayout import GridLayout from kivy.uix.boxlayout import BoxLayout from kivy.uix.label import Label from kivy.uix.textinput import TextInput from kivy.uix.button import Button class LoginScreen ( GridLayout ): def __init__ ( self ): super (LoginScreen, self ).__init__() self .rows = 3 self .cols = 2 self .add_widget(Label( text = 'User Name' )) self .username = TextInput( multiline = False ) self .add_widget( self .username) self .add_widget(Label( text = 'password' )) self .password = TextInput( password = True , multiline = False ) self .add_widget( self .password) self .add_widget(Button( text = 'Submit' )) class MyApp ( App ): def build ( self ): return LoginScreen() if __name__ == '__main__' : MyApp().run()

Python - Kivy Installation guide and Sample code

Kivy Installization Guide runcommand in Run python -m pip install --upgrade pip wheel setuptools python -m pip install docutils pygments pypiwin32 kivy.deps.sdl2 kivy.deps.glew python -m pip install kivy Kivy - Package sample code import kivy kivy.require('1.9.0') from kivy.app import App from kivy.uix.button import Label class HelloKivy(App):     def build(self):         return Label(text="Hello Kivy") helloK = HelloKivy() helloK.run()

Python Selenium - Chome_Default_Download_Folder_Path_Change

#Chome_Default_Download_Folder_Path_Change from selenium import webdriver import os #Get Current folder path dir_path = os.path.dirname(os.path.realpath( __file__ )) options = webdriver.ChromeOptions() options.add_experimental_option( "prefs" , { "download.default_directory" : dir_path + ' \\ Melody songs' , "download.prompt_for_download" : False , "download.directory_upgrade" : True , "safebrowsing.enabled" : True }) driver = webdriver.Chrome( chrome_options =options)

Selenium_Webdriver_Wait - Python

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.by import By import selenium.webdriver.support.ui as ui from selenium.webdriver.support.ui import WebDriverWait import selenium.webdriver.support.expected_conditions as EC import os import time options = webdriver.ChromeOptions() options.add_argument( '--ignore-certificate-errors' ) options.add_argument( '--ignore-ssl-errors' ) dir_path = os.path.dirname(os.path.realpath( __file__ )) #Update Selenium chrome driver folder path here chromedriver = dir_path + "/chromedriver" os.environ[ "webdriver.chrome.driver" ] = chromedriver driver = webdriver.Chrome( chrome_options =options, executable_path = chromedriver) time.sleep( 1 ) driver.get( "http://www.hungama.com/" ) driver.maximize_window() element = WebDriverWait(driver,

pymsgbox - python message box

#This tutorial for to get a confirmation from the user by promting window #Python package "pymsgbox" needs to be install before run this below code #To install "pymsgbox" package go to command prompt and type in "PIP3 INSTALL pymsgbox" import pymsgbox #Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on. replyV = pymsgbox.confirm( text = 'Please login your application and click on on okay' , title = 'Login Confirmation' , buttons =[ 'OK' , 'Cancel' ]) print (replyV) #Displays a simple message box with text and a single OK button. Returns the text of the button clicked on. replyV = pymsgbox.alert( text = 'Please confirm!' , title = '' , button = 'OK' ) print (replyV) #Displays a message box with text input,

python Selenium - Hungama music website automation sample

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.by import By import selenium.webdriver.support.ui as ui import selenium.webdriver.support.expected_conditions as EC import os import time options = webdriver.ChromeOptions() options.add_argument( '--ignore-certificate-errors' ) options.add_argument( '--ignore-ssl-errors' ) dir_path = os.path.dirname(os.path.realpath( __file__ )) #Update Selenium chrome driver folder path here chromedriver = dir_path + "/chromedriver" os.environ[ "webdriver.chrome.driver" ] = chromedriver driver = webdriver.Chrome( chrome_options =options, executable_path = chromedriver) time.sleep( 1 ) driver.get( "http://www.hungama.com/" ) driver.maximize_window() #driver.find_element_by_class_name("video_clk") driver.find_element_by_xpath( &q

openpyxl - Python excel automation package sample code(Create a new excel workbook)

from openpyxl import Workbook wb = Workbook() # grab the active worksheet ws = wb.active # Data can be assigned directly to cells ws[ 'A1' ] = 42 # Rows can also be appended ws.append([ 1 , 2 , 3 ]) # Python types will automatically be converted import datetime ws[ 'A2' ] = datetime.datetime.now() # Save the file wb.save( "sample.xlsx" )

pymsgbox - python package for message box

#This tutorial for to get a confirmation from the user by promting window #Python package "pymsgbox" needs to be install before run this below code #To install "pymsgbox" package go to command prompt and type in "PIP3 INSTALL pymsgbox" import pymsgbox #Displays a message box with OK and Cancel buttons. Number and text of buttons can be customized. Returns the text of the button clicked on. replyV = pymsgbox.confirm( text = 'Please login your application and click on on okay' , title = 'Login Confirmation' , buttons =[ 'OK' , 'Cancel' ]) print (replyV) #Displays a simple message box with text and a single OK button. Returns the text of the button clicked on. replyV = pymsgbox.alert( text = '' , title = '' , button = 'OK' ) print (replyV) #Displays a message box with text input, and OK & Cancel buttons. Returns the text entered, or None if Cancel was clicked. replyV1 = pyms

Selenium chrome driver automation sample code

import selenium import time from selenium import webdriver import chromedriver_binary browser=webdriver.Chrome() browser.get( "https://google.com/" ) username=browser.find_element_by_id( 'logonuidfield' ) username.send_keys( "xxxxxx" ) password=browser.find_element_by_id( 'logonpassfield' ) password.send_keys( "yyyyyyyy" ) login=browser.find_element_by_name( 'uidPasswordLogon' ) login.click() browser.implicitly_wait( 30 ) time.sleep( 3 ) browser.switch_to.frame( 'iframe' ) time.sleep( 10 ) browser.switch_to.frame( 'iframe' ) time.sleep( 10 ) browser.find_element_by_xpath( "//*[contains(text(),'PAAT_Test')]/parent::span/parent::a" ).click()

Selenium Chrome Automation for windows 10 machine

from selenium import webdriver from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.common.by import By import selenium.webdriver.support.ui as ui import selenium.webdriver.support.expected_conditions as EC import os import time options = webdriver.ChromeOptions() options.add_argument( '--ignore-certificate-errors' ) options.add_argument( '--ignore-ssl-errors' ) dir_path = os.path.dirname(os.path.realpath( __file__ )) chromedriver = dir_path + "/chromedriver" print ( 'dir_path' ) os.environ[ "webdriver.chrome.driver" ] = chromedriver driver = webdriver.Chrome( chrome_options =options, executable_path = chromedriver) time.sleep( 1 ) driver.get( "https: \\ www.google.com" ) driver.close