Sunday, 6 December 2015

ssh db connectivity

manual steps:
login forticlient

putty prodip port 2022
ssh ip2
redirects to mysql ip3

with SSHTunnelForwarder(
         ('ip1', 2022),
         ssh_password="user1",
         ssh_username="pwd1",
         remote_bind_address=('ip3', 3306)) as server:
            db = MySQLdb.connect(host='127.0.0.1',
                       port=server.local_bind_port,
                       user='sql_user',
                       passwd='sql pwd',
                       db='sql db')
            with db:
                cur = db.cursor()

Uncertain alert

 try:
            WebDriverWait(self.driver, 5).until(EC.alert_is_present(),
                                   'Timed out waiting for PA creation ' +
                                   'confirmation popup to appear.')

            alert = self.driver.switch_to_alert()
            alert.accept()
            print "alert accepted"
        except TimeoutException:
            print "no alert"

Authenticate during redirection

autoit.win_wait_active("Authentication Required",20)     ie window name is Authentication Required
 autoit.send("username{TAB}password{TAB}{ENTER}")

Thursday, 3 December 2015

Authentication at website level

self.driver.get("https://username:password@abcd.html")

Writing to blinking inputbox

from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.keys import Keys

actions = ActionChains(self.driver)
        actions.send_keys('dummylogin')
        actions.perform()

Current URL

b=self.driver.current_url

DB connection

db = MySQLdb.connect(host="205.23.1.45",user="testuser",db="nameofdb",port=3306,passwd="pwd")
        with db:
            cur = db.cursor()
               cur.execute("select * from abc where def=%s",order_no)
            rows = cur.fetchone()
            my_result=rows[0]
            self.assertEqual('101',str(rows[1]) )