Skip to content Skip to sidebar Skip to footer

I Tried To Update All The Existing Value Under My Profile But Its Not Working - Python Selenium

So I wanted to update all the existing value under my profile and during the execution I can see that the new value is being entered in the text field however as soon as my script

Solution 1:

I have update for 1 of the fields, try to check it out:

import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

driver = webdriver.Chrome()

driver.get('you_site')

driver.find_element_by_link_text('SIGN IN').click()
time.sleep(1)

# enter credentials
welcome = driver.find_element_by_xpath("//h1[contains(text(),'Welcome back!')]")
user_email = driver.find_element_by_name('email').send_keys("email")
user_pass = driver.find_element_by_name('password').send_keys("password")
driver.find_element_by_link_text('SIGN IN').click()

print(welcome.text)
print(driver.title)
print("sign in passed")

wait = WebDriverWait(driver, 5)
profile_id = wait.until(EC.presence_of_element_located((By.XPATH, "//header/div[1]/div[1]/img[1]")))
profile_id.click()
time.sleep(3)
prof_ele = driver.find_element_by_xpath("//a[contains(text(),'Edit Profile')]")
log_out = driver.find_element_by_xpath("//button[contains(text(),'Logout')]")
print(prof_ele.text)
print(log_out.text)
prof_ele.click()

# Name
driver.find_element_by_xpath("//input[@name='name']/following-sibling::*").click()
name_ele = driver.find_element_by_xpath(
    "//input[@name='name']")
name_ele.clear()
name_ele.send_keys("My name is John")

# NickName
driver.find_element_by_xpath("//input[@name='display_name']/following-sibling::*").click()
name_ele = driver.find_element_by_xpath(
    "//input[@name='display_name']")
name_ele.clear()
name_ele.send_keys("My name is NickName")

I would suggest using XPATH engine and read a bit about it, it really powerful and trying avoid entirely obsolute selectors, like:

//body/div[@id='root']/div[2]/div[2]/form[1]/div[2]/div[2]/div[1]/div[1]/*[1]

and replace on dynamic ones, like:

//input[@name='name']/following-sibling::*

Post a Comment for "I Tried To Update All The Existing Value Under My Profile But Its Not Working - Python Selenium"