I want to know if there's any method which can make me check if elements is displayed on UI faster. I've compared that if the element is shown on UI, then my code will be quickly get the result, while, if the element is not shown on UI, my code will take a long time to get the result. Why?
from selenium.common.exceptions import NoSuchElementException
from selenium import webdriver
def is_OS_Present(Des,driver):
td_OS_section=driver.find_element_by_id("CONTROL_OS_CTO_Options")
try :
td_OS_section.find_element_by_xpath("//label[contains(text(),'%s')]" %Des)
print 'ele is displayed'
except NoSuchElementException:
print 'ele is not displayed'
driver=webdriver.Firefox()
driver.get("https://www-01.ibm.com/products/hardware/configurator/americas/bhui/launchNI.wss")
driver.find_element_by_id("modelnumber").send_keys('5458AC1')
driver.find_element_by_name("submit").click()
is_OS_Present('RHEL Server 2 Skts 1 Guest Prem RH Support 1Yr (5731RSR) ',driver)
is_OS_Present('abc',driver)