1

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")

picture: enter image description here

1
  • when I change the value of the area.select_by_index(1) then it selects the option but did not send values in the phone number option. Commented Feb 8, 2021 at 7:25

1 Answer 1

1

Just use implicit wait , you can also use explicit wait for each element also:

driver = webdriver.Chrome(executable_path="C:\\chromedriver.exe")
driver.implicitly_wait(10)
driver.get("https://aujtravels.com/easyneasy/")
7
  • not working did not send number in the phone number fields Commented Feb 9, 2021 at 8:47
  • I tried your code and it works
    – PDHide
    Commented Feb 9, 2021 at 8:56
  • Just added this implicit wait to that code
    – PDHide
    Commented Feb 9, 2021 at 8:56
  • i have added it in my code but when it comes to the phone number edit field it did not send keys and then go to the next and the script runs correctly and at the last, it generates a screenshot for me I will share my screen shot with path kindly check Commented Feb 10, 2021 at 5:46
  • screenshot path :C:\Users\LENOVO L540\PycharmProjects\pythonProject\screen.png Commented Feb 10, 2021 at 5:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.