I have problems: first, it did not send keys to the phone number, and the second when I select the value in a dropdown it shows me this error.
CONSOLE ERROR:
Traceback (most recent call last):
File "C:\Users\LENOVO L540\PycharmProjects\pythonProject\EasyNeasy.py", line 49, in <module>
area.select_by_visible_text('DHA')
File "C:\Users\LENOVO L540\PycharmProjects\pythonProject\venv\lib\site-packages\selenium\webdriver\support\select.py", line 140, in select_by_visible_text
raise NoSuchElementException("Could not locate element with visible text: %s" % text)
selenium.common.exceptions.NoSuchElementException: Message: Could not locate element with visible text: DHA
PYTHON SCRIPT:
import time
from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.get("https://aujtravels.com/easyneasy/")
driver.maximize_window()
action = ActionChains(driver)
menu=driver.find_element_by_css_selector("li[class='list-inline-item cart-btn drop mr-0'] a[class='btn btn-link border-none']")
action.move_to_element(menu).perform()
childmenu =driver.find_element_by_xpath("//a[contains(text(),'Login')]")
action.move_to_element(childmenu).click().perform()
driver.find_element_by_id("email").send_keys("[email protected]")
driver.find_element_by_name("password").send_keys("123456")
driver.find_element_by_tag_name("button").click()
#print(driver.find_element_by_xpath("//div[@class='toast-message']").text)
time.sleep(3)
driver.find_element_by_xpath("//input[@name='keyword']").send_keys("product")
driver.find_element_by_css_selector("[class*='search-form__submit form-btn form-btn--2']").click()
time.sleep(2)
driver.find_element_by_xpath("//h5[contains(text(),'Product Dummy 7')]").click()
driver.execute_script("window.scrollTo(0, 200)")
driver.find_element_by_class_name("checkmark").click()
driver.find_element_by_css_selector("button[class='btn btn-secondary btn-lg font-ubuntu']").click()
driver.find_element_by_xpath("//a[@href='https://aujtravels.com/easyneasy/cart']//img").click()
driver.find_element_by_xpath("//label[contains(@class,'checkbox-design m-auto p-0 d-inline-block m-checkbox')]//span[contains(@class,'checkmark')]").click()
time.sleep(1)
driver.find_element_by_css_selector("#plusButtonId5").click()
time.sleep(1)
print(driver.find_element_by_xpath("//div[contains(text(),'Cart updated successfully')]").text)
time.sleep(3)
driver.find_element_by_css_selector("#proceed_btn").click()
time.sleep(1)
driver.find_element_by_xpath("//a[contains(text(),'+ Add New Address')]").click()
time.sleep(2)
driver.find_element_by_xpath("//a[contains(text(),'Add New Address')]").click()
time.sleep(2)
driver.find_element_by_css_selector("#name").send_keys("Arsal")
time.sleep(2)
driver.find_element_by_xpath("//input[@id='phone']").send_keys("12345678901")
driver.find_element_by_id("address").send_keys("8")
driver.find_element_by_xpath("//input[@id='street']").send_keys("ghang Road ")
cities =Select(driver.find_element_by_css_selector("#city_id"))
cities.select_by_visible_text('Karachi')
area=Select(driver.find_element_by_xpath("//select[@id='district_id']"))
time.sleep(2)
area.select_by_visible_text('DHA')
driver.find_element_by_css_selector("#zip_code").send_keys("39350")
driver.find_element_by_xpath("//label[@for='shipping_address']").click()
driver.find_element_by_css_selector("#add_address_btn").click()
driver.get_screenshot_as_file("screen.png")