Skip to content

Day 16 Selenium 4.3.* changes #148

Open
@philiplawlor

Description

@philiplawlor

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()
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions