Python Selenium Xpath get text -
please how can find text invalid email address.
inside xpath:
driver.find_element_by_xpath(".//*[@id='create_account_error']/ol/li")
and verify assert?
you can check website - http://automationpractice.com/index.php?controller=authentication
put in wrong email address in "create account tab" , click "create account", , see error message.
how can verify error message xpath make sample test case?
i giving sample code work want, put in testcase accordingly .
from selenium import webdriver selenium.webdriver.support.ui import webdriverwait selenium.webdriver.support import expected_conditions ec selenium.webdriver.common.by import url="http://automationpractice.com/index.php?controller=authentication" driver =webdriver.chrome() driver.maximize_window() driver.get(url) driver.find_element(by.id,'email_create').send_keys("this test") driver.find_element(by.id,'submitcreate').click() webdriverwait(driver,10).until(ec.presence_of_element_located((by.css_selector, "#create_account_error > ol > li"))) ele=driver.find_element(by.css_selector,'#create_account_error > ol > li') assert ele.text == 'invalid email address.' driver.quit()
Comments
Post a Comment