Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 16 Selenium 4.3.* changes #148

Open
philiplawlor opened this issue Sep 27, 2023 · 0 comments
Open

Day 16 Selenium 4.3.* changes #148

philiplawlor opened this issue Sep 27, 2023 · 0 comments

Comments

@philiplawlor
Copy link

Selenium made several changes, especially to find_element and find_elements and they depreciated the find_by_* calls.

Documentation on "https://selenium-python.readthedocs.io/installation.html" is outdated
Best Documentation can be found on "https://www.selenium.dev/documentation/webdriver/elements/locators/"

The following code can log users into Instagram and clear the 2 messages as of 27 Sept 2023

HTH

`import getpass
#my_password = getpass.getpass("What's your password?\n")
#print(my_password)

from conf import INSTA_USERNAME, INSTA_PASSWORD
from selenium import webdriver
from selenium.webdriver.common.by import By ##***Helpful in 4.3.

import time

browser = webdriver.Chrome()
url = 'https://instagram.com'
browser.get(url)
time.sleep(1)

username_el = browser.find_element(By.NAME,'username').send_keys(INSTA_USERNAME)
password_el = browser.find_element(By.NAME,'password').send_keys(INSTA_PASSWORD)
submit_btn_el = browser.find_element(By.XPATH, "//button[@type='submit']");
time.sleep(1)
submit_btn_el.click()
time.sleep(3)

body_el = browser.find_element(By.CSS_SELECTOR,"body")
html_text = body_el.get_attribute("innerHTML")
"""
Need to clear the Save your login

Not Now
"""

not_now_el = browser.find_element(By.XPATH, "//div[contains(text(),'Not Now')]")
not_now_el.click()

"""
Also need to clear the Turn on Notifications
"""

notifications_not_now_el = browser.find_element(By.XPATH, "//button[contains(text(),'Not Now')]")
notifications_not_now_el.click()
`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant