Skip to content

Instantly share code, notes, and snippets.

@ashim888
Created June 2, 2013 15:28
Show Gist options
  • Save ashim888/5693851 to your computer and use it in GitHub Desktop.
Save ashim888/5693851 to your computer and use it in GitHub Desktop.
python Automation Phase I
#-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Ashim
#
# Created: 14/05/2013
# Copyright: (c) Ashim 2013
# Licence: <your licence>
#-------------------------------------------------------------------------------
import wx
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
class MyMain(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,parent=None,title='FaceBot',size=(300,200))
self.FirstWindow()
def FirstWindow(self):
panel=wx.Panel(self)
#BOX
vbox=wx.BoxSizer(wx.VERTICAL)
#creating horizontal contents
hbox1=wx.BoxSizer(wx.HORIZONTAL)
hbox2=wx.BoxSizer(wx.HORIZONTAL)
hbox3=wx.BoxSizer(wx.HORIZONTAL)
#Define the items for first Row
self.login_text=wx.StaticText(panel,label='Email/Phone')
self.login_box=wx.TextCtrl(panel,size=(20,20))
#Items for Second Row
self.password_text=wx.StaticText(panel,label='Password')
self.password_box=wx.TextCtrl(panel,size=(20,20))
#items for Third Row
self.button=wx.Button(panel,label="Login")
self.Bind(wx.EVT_BUTTON,self.getvalue,self.button)
#place items in the horizontal row
hbox1.Add(self.login_text,flag=wx.Right,border=8)
hbox1.Add(self.login_box,proportion=1)
hbox2.Add(self.password_text,flag=wx.Right,border=8)
hbox2.Add(self.password_box,proportion=1)
hbox3.Add(self.button)
#Adding Everython in the Frame
vbox.Add(hbox1, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
vbox.Add((-1,10))
vbox.Add(hbox2, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
vbox.Add((-1,10))
vbox.Add(hbox3, flag=wx.EXPAND|wx.LEFT|wx.RIGHT|wx.TOP, border=10)
panel.SetSizer(vbox)
def getvalue(self,event):
self.a=self.login_box.GetValue()
self.b=self.password_box.GetValue()
driver= webdriver.Firefox()
driver.get("https://www.facebook.com")
elem=driver.find_element_by_name("email")
elem.send_keys(self.a)
elem1=driver.find_element_by_name("pass")
elem1.send_keys(self.b)
btn=driver.find_element_by_id("loginbutton")
#btn.send_keys(Keys.ENTER)
btn.submit()
home=driver.find_element_by_id('pageLogo')
home.click()
if __name__=='__main__':
app=wx.App()
MyMain().Show()
app.MainLoop()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment