Saturday, July 8, 2023

Selenium with Python: Frames 


element = driver.switch_to.active_element

alert = driver.switch_to.alert
driver.switch_to.default_content()
driver.switch_to.frame('frame_name')
driver.switch_to.frame(1)
driver.switch_to.frame(driver.find_elements(By.TAG_NAME, "iframe")[0])
driver.switch_to.parent_frame()
driver.switch_to.window('main')
Example:
#driver.get("https://testlayers.staging.senegalsoftware.com/JobPosts/create?id=326D4402-25C1-4D7E-81DB-23DA5AF14111&step=2")
driver.switch_to.frame(driver.find_element(By.XPATH, '//*[@id="cke_1_contents"]/iframe'))
driver.find_element(By.TAG_NAME, "p").send_keys("Dentist")
driver.switch_to.parent_frame()

Tuesday, March 15, 2022

Hacker Rank 30 day code Challenge (Inheritance and constructor in python)

 Hacker Rank 30 day code Challenge (Inheritance and constructor in python)

Problem:

The parent class is Person. Make a subclass Student. The Student has attributes first name, last name, Id, Scores.

Input: First Name, Last Name, ID, Number of scores (e.g 2 or 3) , Scores

Take the average of scores and print.

(Starting Person class code and Ending code is already provided in hacker rank editor)

class Person:
    def __init__(self, firstName, lastName, idNumber):
        self.firstName = firstName
        self.lastName = lastName
        self.idNumber = idNumber
    def printPerson(self):
        print("Name:"self.lastName + ","self.firstName)
        print("ID:"self.idNumber)

        
class Student(Person):
    def __init__(self, firstName, lastName, idNumber,scores):
        self.firstName = firstName
        self.lastName = lastName
        self.idNumber = idNumber
        self.scores = scores


    def calculate(self):
        sumscore=0
        for i in range(numScores):
            sumscore = sumscore +int(scores[i])
            avg = sumscore / numScores
       
        if avg >=90.0 and avg<=100.0:
            return 'O'
        elif avg >=80.0 and avg<=90.0:
            return 'E'
        elif avg>=70.0 and avg<=80.0:
            return 'A'
        elif avg>=55.0 and avg<=70.0:
            return 'P'
        elif avg>=40.0 and avg<=55.0:
            return 'D'
        else:
            return'T'



  

line = input().split()
firstName = line[0]
lastName = line[1]
idNum = line[2]
numScores = int(input()) # not needed for Python
scores = listmap(intinput().split()) )
s = Student(firstName, lastName, idNum, scores)
s.printPerson()
print("Grade:", s.calculate())

Monday, March 14, 2022

Hacker Rank 30 day code challenge Python

 Problem:

Convert a number 'n' to its binary base 2. Find base 10 integers 0,1. Find max number of consecutive 1's.

import math

no = int(input())
arr = []
while no // 2 > 0:
remainder = no % 2
arr.append(remainder)
no = no // 2

arr.append(no)
max = []

count = 0
for i in arr:

if i == 1:
count = count + 1
max.append(count)
else:
count = 0

max.sort()

print(max[-1]) 

Tuesday, March 8, 2022

Hacker Rank 30 Day Challenge(Recursion-Factorial Program)

 Hacker Rank 30 Day Challenge(Recursion-Factorial Program)

Problem:

For a number n entered by the user, calculate its factorial. Use recursion to calculate.

Example:

n=4

Factorial of 4 is : 4x3x2x1

Factorial of 5 is: 5x4x3x2x1

#!/bin/python3

import math
import os
import random
import re
import sys

#
# Complete the 'factorial' function below.
#
# The function is expected to return an INTEGER.
# The function accepts INTEGER n as parameter.
#

def factorial(n):
i=1
r=1
for i in range(n):
r=r*(i+1)
i=i+1
return r


n=int(input().strip())

result = factorial(n)
print(result)

Monday, March 7, 2022

Split() method in Python

Split() method:

  • Splits the string into a list of words. 
  • You can specify a separator (e.g ' '' !)
  • The default separator is whitespace.
  • We can take string input from the user. Use the split method and add the input to dictionary key-value pairs.

For example:

for i in range(n):
name=input()
phoneNum=name.split()
PhoneBook[phoneNum[0]]= phoneNum[1]

Another example:

string="Hello click this link"
list=string.split()
print(list)
OUTPUT:
['Hello', 'click', 'this', 'link']

Process finished with exit code 0

HackerRank 30 day challenge Python (Dictionaries)

HackerRank 30 day challenge Python (Dictionaries)
Problem:
Creating a phone book with names and phone numbers. Taking Input from user to search names in the dictionary and display the numbers in the format name=number.

n = int(input().strip())
PhoneBook={}


for i in range(n):
 name=input()
 phoneNum=name.split()
 PhoneBook[phoneNum[0]]= phoneNum[1]


while True:
  try:
   find = input().strip()
  except EOFError as e:
   break
  if find not in PhoneBook.keys():
    print("Not found")
  elif find in PhoneBook.keys():
   print(f'{find}={PhoneBook.get(find)}')




Sunday, March 6, 2022

HackerRank 30 day code challenge Day 7

 HackerRank 30 day code challenge Day 7

Problem:

Take input N this is the length of the array. Take input elements of the array of (length N). Elements are all integers. Print this array in reverse order on the same line and space separated.


import math
import os
import random
import re
import sys

n = int(input().strip())
arr=[]
arr = list(map(int, input().rstrip().split()))

i=len(arr)-1
#print(i)
while i<len(arr) and i>-1:
print(f'{arr[i]}' + " " ,end='')
i=i-1


Output:
6
1 2 3 4 5 6
6 5 4 3 2 1 
Process finished with exit code 0

Thursday, March 3, 2022

 HackerRank 30 Day Code Challenge(Day 6)

Problem:

Taking n input strings, separate each string's odd and even indexes and print the even-odd characters in form of two space-separated strings on a single line.

n=int(input())
x=0
evenstr=""
oddstr=""
i=0
for x in range(0,n):
s=input()
evenstr = ""
oddstr = ""

for i in range(0, len(s)):
if i % 2 == 0:
evenstr = evenstr + s[i]
elif i % 2 != 0:
oddstr = oddstr + s[i]
print(evenstr +' '+ oddstr )




 HackerRank Problem(30-day challenge)

Writing a table of number n:

import math
import os
import random
import re
import sys



n = int(input().strip())
i=1
for i in range(1,11):
print(f'{n}*{i}={n*i}')
i+=1

Monday, May 31, 2010

Meeting (Tips)

  • Give Suggestions about process improvement.
  • Always talk and dicuss with logics.
  • Suggest alternate ways of doing things.
  • Always smile.
  • Keep things cool and calm, dont take things too serioulsy.
  • Even if you have to say "No" say it with a smile.

Saturday, May 29, 2010

Bhalay dino baat hai..


Bhalay dino ki baat hai,
Bhali si ik shakal thi,
Bhali si us ki dosti…

Na ye kay husn-e-taam ho,
Na dekhnay main aam si,
Na ye kay wo chalay to ,
Kehkishan say rah guzar lagay,
Magar wo sath ho to phir,
Bhala bhala safar lagay

Koi bhi rut ho us ki jab,
Fiza ka rang roop thi,
Wo garmiyon ki chaoon thi,
Wo sardiyon ki dhoop thi.

Na mudatoon juda rahay
Na sath subh-o-sham ho
Na rishta-e-wafa pay zid
Na ye kay izne-aam ho

Na aisi khush libasiyan
Kay sadgii gila karay
Na itni bay-takalufi
Kay aina haya karay

Na ikhtalaf main wo rang
Kay bad-maza hon khwahishain
Na is kadar supurdgi
Kay zich karain nawazisheen

Na ashqi junon ki
Kay zindagi azab ho,
Na is kadar khatoor pan,
Kay dosti kharab ho

Kabhi to baat bhi khafi,
Kabhi sakoot bhi sukhan
Kabhi to kasht-e-zafran
Kabhi udasiyon ka ban

Suna hai….
Suna hai ik umar hai
Mu’amlat-e-Dil ki bhi
Visal-e-jan fiza to kya
Faraq-e-jan vasl ki bhi

So aik roz kya howa,
Wafa pay behaas chir gaye,
Main ishq ko amar kahon,
Wo meri zid say chir gaye

Main ishq ka aseer tha
Wo ishq ko qafas kahay,
Kay umar bhar kay saath ko
Bad-taraz hawas kahay

Shajar hajar nahi kay ham
Hamesha paba-e-gil rahain'
Na door hain kay rasiyan
Galay main mustakil rahain

Muhabaton ki vusa’teen
Hamaray dast-o-pa main hain
Bas aik dars-e-nisbateen
Sagan-e-bawafa main hain

Main koi painting nahi,
Kay aik frame main rahon,
Wohi jo maan ka meet ko
Usi kay praim mian rahon

Tumhari sooch job hi ho
Main is mizaaj ki nahi
Mujhay wafa say bair hai
Ye baat aj ki nahi

Na us ko mujh pay maan tha
Na mujh ko us pay zuam hi
Jab ehad hi koi na ho
To kya gham-e-shikistagi

So apna apna rasta
Hansi khusi dabal liya
Wo apni rah chal pari
Main apni rah chal diya

Bhali si aik shakal thi
Bhali si us ki dosti

Ab us ki yaad raat din nahi
Han magar kabhi kabhi..
Han magar kabhi kabhi..

Selenium with Python: Frames   element = driver . switch_to . active_element alert = driver . switch_to . alert driver . switch_to . de...