Skip to content

Commit 94ec934

Browse files
committedJun 28, 2024
day5
1 parent aff1685 commit 94ec934

File tree

7 files changed

+108
-0
lines changed

7 files changed

+108
-0
lines changed
 

‎.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
/env
22
.env
3+
env/

‎Day_05/.env.example

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EMAIL = ""
2+
PASS = ""

‎Day_05/final/1.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from selenium import webdriver
2+
import time
3+
4+
driver = webdriver.Firefox()
5+
6+
driver.get("https://www.google.com")
7+
8+
time.sleep(10)
9+
10+
driver.quit()

‎Day_05/final/2.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.action_chains import ActionChains
3+
from selenium.webdriver.common.keys import Keys
4+
5+
driver = webdriver.Firefox()
6+
7+
driver.get("https://www.google.com")
8+
9+
actions = ActionChains(driver)
10+
actions.send_keys("Hello Selenium").key_down(Keys.ENTER).perform()

‎Day_05/final/3.py

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.action_chains import ActionChains
3+
4+
inp = input("Search for an video:")
5+
6+
driver = webdriver.Firefox()
7+
driver.get(f"https://www.youtube.com/results?search_query={inp}")
8+
driver.find_element("id", "video-title").click()
9+
10+
action = ActionChains(driver)
11+
action.send_keys("f").perform()

‎Day_05/final/4.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
from selenium import webdriver
2+
from selenium.webdriver.common.action_chains import ActionChains
3+
from selenium.webdriver.common.keys import Keys
4+
from selenium.webdriver.common.by import By
5+
from dotenv import load_dotenv
6+
import os
7+
import time
8+
9+
load_dotenv()
10+
11+
EMAIL = os.environ.get('EMAIL')
12+
PASS = os.environ.get('PASS')
13+
inp = input("Search for a course:")
14+
15+
driver = webdriver.Firefox()
16+
driver.get("https://www.coursera.org/?authMode=login")
17+
18+
action = ActionChains(driver)
19+
action.send_keys(EMAIL)
20+
action.send_keys(Keys.TAB)
21+
action.send_keys(PASS)
22+
action.send_keys(Keys.ENTER)
23+
action.perform()
24+
25+
time.sleep(20)
26+
27+
driver.switch_to.new_window("tab")
28+
driver.get(f"https://www.coursera.org/search?query={inp}")
29+
driver.find_element(By.CLASS_NAME, "cds-ProductCard-gridCard").click()
30+

‎Day_05/final/play.py

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import re
2+
from playwright.sync_api import Playwright, sync_playwright, expect
3+
from dotenv import load_dotenv
4+
import os
5+
import time
6+
7+
load_dotenv()
8+
9+
10+
def run(playwright: Playwright) -> None:
11+
browser = playwright.chromium.launch(headless=False)
12+
context = browser.new_context()
13+
page = context.new_page()
14+
page.goto("http://manaslu.pcampus.edu.np:443/login")
15+
page.locator("input[name=\"email\"]").click()
16+
page.locator("input[name=\"email\"]").fill("078bct045.krishant@pcampus.edu.np")
17+
page.locator("input[name=\"password\"]").click()
18+
page.locator("input[name=\"password\"]").fill(os.environ.get('PASSWORD'))
19+
page.get_by_role("button", name="Login").click()
20+
page.get_by_role("link", name="Projects").click()
21+
page.get_by_role("button", name="+ Add").click()
22+
page.get_by_placeholder("Your Cool Project").fill("test-react-2")
23+
page.get_by_role("button", name="Continue").click()
24+
page.get_by_role("link", name="production").click()
25+
page.get_by_role("link", name="+ Add New Resource").click()
26+
page.get_by_text("Public Repository").click()
27+
page.locator("#repository_url").click()
28+
page.locator("#repository_url").fill("https://github.com/thejungwon/docker-reactjs")
29+
page.get_by_role("button", name="Check repository").click()
30+
time.delay(5)
31+
page.get_by_role("button", name="Disable This Popup", exact=True).click()
32+
page.get_by_role("button", name="Acknowledge & Disable This").click()
33+
page.get_by_text("Build Pack * Nixpacks Static").click()
34+
page.locator("select[name=\"wkow8c0\"]").select_option("Dockerfile")
35+
page.get_by_role("button", name="Continue").click()
36+
page.get_by_role("button", name="Deploy", exact=True).click()
37+
38+
# ---------------------
39+
context.close()
40+
browser.close()
41+
42+
43+
with sync_playwright() as playwright:
44+
run(playwright)

0 commit comments

Comments
 (0)
Please sign in to comment.