-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
163636a
commit e230780
Showing
95 changed files
with
21,598 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Fri Aug 28 09:59:41 2020 | ||
@author: saura | ||
""" | ||
# from selenium import webdriver | ||
from selenium import webdriver | ||
edge_browser = webdriver.Edge('./msedgedriver.exe') | ||
# by default it searches the driver file in the path of Windows folder in the C drive | ||
|
||
# print(edge_browser) | ||
edge_browser.maximize_window() | ||
edge_browser.get('https://www.seleniumeasy.com/test/basic-first-form-demo.html') | ||
|
||
# print('Selenium Easy Demo' in edge_browser.title) | ||
# # we are checking here whether we are on the same page or not, if yes, it will return true | ||
|
||
assert 'Selenium Easy Demo' in edge_browser.title | ||
# # if the above is not true, assert will error out, otherwise code will continue | ||
|
||
show_message_button = edge_browser.find_element_by_class_name("btn-default") | ||
# the above command basically grabs this | ||
# <button type="button" onclick="showInput();" class="btn btn-default">Show Message</button> | ||
|
||
# we can find that button by CSS selector as well, using the below command | ||
# show_message_button = edge_browser.find_element_by_css_selector('#get-input > .btn') | ||
|
||
|
||
# print(button_text) | ||
# print(show_message_button.get_attribute('innerHTML')) | ||
|
||
assert 'Show Message' in edge_browser.page_source | ||
|
||
user_message = edge_browser.find_element_by_id("user-message") | ||
user_message.clear() # to clear any previous message | ||
user_message.send_keys("Hello there!") # selenium is typing the message | ||
|
||
show_message_button.click() # selenium is clicking the button | ||
|
||
output_message = edge_browser.find_element_by_id('display') | ||
|
||
print('Hello there!' in output_message.text) | ||
print(output_message.get_attribute('innerHTML')) | ||
|
||
assert 'Hello there!' in output_message.text | ||
|
||
edge_browser.close() | ||
# edge_browser.quit() # or we can use this | ||
|
||
''' | ||
sometimes the .close() , or .quit() method doesn't work. Because of some backgroud updates, etc. | ||
and each .close() closes one instance only. so in case more than 1 instance of the browser is opened by the | ||
program, we need to pass multiple .close() | ||
many websites identify the use of selenium and blocks the activity. "Verify you are not a robot" checkbox. | ||
so there is a way around that, we use 'Waits' so do things slowly, so the server thinks that this is being | ||
done by a human. | ||
''' |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 12:22:47 2020 | ||
@author: saura | ||
""" | ||
print(bin(10)) | ||
print(int("0b1010",2)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 19:33:39 2020 | ||
@author: saura | ||
""" | ||
is_cool = True | ||
is_cool = False | ||
print(bool(-0)) | ||
print(bool(0)) | ||
print(bool(1)) | ||
print(bool(0.5)) | ||
print(bool('0')) | ||
print(bool('True')) | ||
print(bool('False')) | ||
print(bool(False)) | ||
print(bool('any random thing')) | ||
|
||
# All values are considered "truthy" except for the following, which are "falsy": | ||
# None | ||
# False | ||
# 0 | ||
# 0.0 | ||
# 0j | ||
# Decimal(0) | ||
# Fraction(0, 1) | ||
# [] - an empty list | ||
# {} - an empty dict | ||
# () - an empty tuple | ||
# '' - an empty str | ||
# b'' - an empty bytes | ||
# set() - an empty set | ||
# an empty range, like range(0) | ||
# objects for which | ||
# obj.__bool__() returns False | ||
# obj.__len__() returns 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 12:42:11 2020 | ||
@author: saura | ||
""" | ||
a,b,c = 1,2,3 # we can pass 1,2,3 as list, tuple or set | ||
print(a) | ||
print(b) | ||
print(c) | ||
|
||
print("*" * 10) | ||
|
||
print(list(range(10,100))) | ||
|
||
sentence = '|' | ||
new_sentence = sentence.join(['hi', 'my','name', 'is', 'John']) | ||
print(new_sentence) | ||
|
||
# or | ||
new_sentence2 = '_'.join(['hi', 'my','name', 'is', 'John']) | ||
print(new_sentence2) | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 11:39:08 2020 | ||
@author: saura | ||
""" | ||
# fundamental data types | ||
print(type(2 + 4)) | ||
print(type(2 - 4)) | ||
print(type(2 * 4)) | ||
print(type(2 / 4)) | ||
print(2.1 + 4.9) | ||
print(2 ** 4) | ||
print(10 // 4) | ||
print(10 % 4) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Aug 16 10:35:42 2020 | ||
@author: saura | ||
""" | ||
my_dict = { | ||
'a' : [1,2,3], | ||
'b' : "hello", | ||
'c' : True | ||
} | ||
|
||
my_list = [ | ||
{ | ||
'a' : [1,2,3], | ||
'b' : "hello", | ||
'c' : True | ||
}, | ||
{ | ||
'a' : [4,5,6], | ||
'b' : "bye", | ||
'c' : False | ||
} | ||
] | ||
|
||
print(my_dict["a"]) | ||
print(my_dict["a"][1]) | ||
print(my_list[1]["a"][2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Aug 16 10:58:07 2020 | ||
@author: saura | ||
""" | ||
user = { | ||
"name": "john", | ||
"sex": "M", | ||
"age": 20 | ||
} | ||
|
||
# print(user["height"]) # this will give us error, as height doesn't exit in the dictionary. | ||
|
||
print(user.get("height")) | ||
|
||
print(user.get("height", 6)) # if the key value pair doesn't exit, then it will write the default value. | ||
print(user) | ||
|
||
# new way to create a dictionary | ||
user2 = dict(name = "saurabh", age = 25) | ||
print(user2) | ||
print(user2["name"]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Aug 16 11:10:07 2020 | ||
@author: saura | ||
""" | ||
user = { | ||
"name": "john", | ||
"sex": "M", | ||
"age": 20 | ||
} | ||
|
||
print("john" in user.items()) | ||
print("sex" in user) | ||
|
||
print("john" in user.values()) | ||
print("sex" in user.keys()) | ||
|
||
print(user.items()) # returns a list containing a tuple for each key value pair | ||
|
||
print(user.clear()) | ||
print(user) | ||
|
||
|
||
user2 = { | ||
"name": "pepy", | ||
"sex": "F", | ||
"age": 45 | ||
} | ||
|
||
print(user2.pop("age")) | ||
print(user2) | ||
|
||
print(user2.update({"sex": "M"})) | ||
print(user2) | ||
|
||
print(user2.update({"size": 32})) | ||
print(user2) | ||
|
||
print(user2.popitem()) # it randomly pops an item | ||
print(user2) | ||
|
||
print(user2.keys()) | ||
print(user2.values()) | ||
|
||
|
||
user3 = { | ||
'age': 45, | ||
'username': "john", | ||
'weapons': ["gun"], | ||
'is_active': True, | ||
'clan': "army" | ||
} | ||
|
||
user3['weapons'].append('shield') | ||
user3["weapons"] = user3["weapons"] + ["pistol"] | ||
print(user3) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 13:16:31 2020 | ||
@author: saura | ||
""" | ||
weather = "\tIt\'s a nice weather.\nHope to have a \"really\" good day." | ||
print(weather) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 10:57:01 2020 | ||
@author: saura | ||
""" | ||
name = input("What is your name? ") | ||
print("Your name is " + name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 13:27:36 2020 | ||
@author: saura | ||
""" | ||
name = 'john' | ||
age = 12 | ||
print("Hi " + name + ". You are " + str(age) + " years old.") | ||
# or we can use formatted strings | ||
print(f"Hi {name}. You are {age} years old.") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 12:44:07 2020 | ||
@author: saura | ||
""" | ||
int | ||
float | ||
complex | ||
str | ||
bool | ||
list | ||
tuple | ||
set | ||
dict | ||
None | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sun Aug 16 10:31:57 2020 | ||
@author: saura | ||
""" | ||
a,b,c,*other,d = [1,2,3,4,5,6,7,8,9,0] # this will work with set, tuple and normal (as in 1,2,3,4,5) also. | ||
# and it always store the variables as list, if more than one item, otherwise as int. | ||
|
||
print(type(a)) | ||
print(b) | ||
print(c) | ||
print(other) | ||
print(type(other)) | ||
print(d) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
Created on Sat Aug 15 19:54:30 2020 | ||
@author: saura | ||
""" | ||
li = [1, 2.5, "hello", True] | ||
print(li) | ||
|
||
amazon_cart = [ | ||
"laptop", | ||
"book", | ||
"phone", | ||
"pen", | ||
"key" | ||
] | ||
# start:stop:stepover | ||
print(amazon_cart[0]) | ||
print(amazon_cart[::-1]) | ||
print(amazon_cart[0:2]) | ||
print(amazon_cart) | ||
|
||
print("\nPart-2") | ||
new_cart = amazon_cart # here we are actually passing the address of the old list, | ||
# and not copying and storing the list in new location. | ||
new_cart[0] = "PC" # lists are mutable, unlike strings which are immutable. | ||
print(amazon_cart) # notice that the old list is also modified. | ||
print(new_cart) | ||
|
||
print("\nPart-3") | ||
flipkart_cart = amazon_cart[:] # here we are actually copying the whole list to another location or we can use .copy() | ||
flipkart_cart[0] = "headphones" | ||
print(amazon_cart) | ||
print(flipkart_cart) | ||
|
||
print("\nPart-4") | ||
my_list = [1,2,3] | ||
bonus = my_list + [5] | ||
my_list[0] = 'z' | ||
print(my_list) | ||
print(bonus) |
Oops, something went wrong.