I am locating an element on http://ntry.com/#/stats/ladder/round.php, but I keep failing locating it, after trying several ways, including ind_element_by_css_selector, ind_element_by_xpath... and so on.
Even though I used WebDriverWait, I keep failing. What would be the Problem?
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver import ActionChains
driver = webdriver.Firefox()
driver.get("http://ntry.com/#/stats/ladder/round.php")
try:
element = EC.presence_of_element_located((By.XPATH, '//div[@id="analysis-table"]/div[1]/div[1]/p[1]/span[1]/strong'))
#or element = WebDriverWait(driver, 30).until(
EC.presence_of_element_located((By.CSS_SELECTOR, "#analysis-table>div.bar_graph>div:nth-child(1)>p.left.on>span.per>strong"))
)
except:
print "HIJUDE"
driver.quit()
I used Implicit wait, but that also makes same error. Not using Wait makes NoSuchElementException too.
selenium.common.exceptions.NoSuchElementException: Message: Unable to locate element: {"method":"xpath","selector":'//div[@id="analysis-table"]/div[1]/div[1]/p[1]/span[1]/strong'}
Is the website related with being unable to find the Element? or using method other than Xpath or css_selector would do? I am pretty confused why this happened.
-------------Edit-------------- I found out that there is iframe at the upper xpath level of div[@id="analysis-table"]. I guess that's the reason. Should I always use driver.switch_to_frame() in this case? Btw, is driver.switch_to_window() different from frame()?
iframeelement you will need to switch to the frame and then it should be able to find the element. - DarthOpto