0

Numbers are in chart I am trying to get numbers such as 14,401. I tried something like

WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//iframe[@id='wiz-iframe-intent']")))
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//*[@id="highcharts-5tawcvw-0"]/svg/g[8]/g[1]/text/tspan[1]'))).text

getting TimeOut Exception.

6
  • Can you share the HTML in text format. Commented Jul 31, 2018 at 11:19
  • <tspan x="0" y="11" class="highcharts-text-outline" fill="#000000" stroke="#000000" stroke-width="2px" stroke-linejoin="round" style="">14,401 (100%)</tspan> Commented Jul 31, 2018 at 11:23
  • Are you sure that you are in iframe ? Commented Jul 31, 2018 at 11:25
  • yes I am sure of it Commented Jul 31, 2018 at 11:27
  • @AbhishekGupta The elements you are trying to interact with are from the svg namespace. This discussion Selenium WebDriver Java: How to Click on elements within an SVG using XPath may help you. Commented Jul 31, 2018 at 11:37

1 Answer 1

1

That particular element is in SVG. you can follow this code :

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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.common.action_chains import ActionChains
from selenium.webdriver.support.select import Select
import time

driver = webdriver.Chrome(executable_path = r'D:/Automation/chromedriver.exe')
driver.maximize_window()
driver.get("https://eu1.dashboard.clevertap.com/login.html")

wait = WebDriverWait(driver, 20)
action = ActionChains(driver)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,"wiz-iframe-intent")))
wait.until(EC.element_to_be_clickable((By.XPATH, "//div[@class='CT_Interstitial']//span[@class='CT_InterstitialClose']"))).click()

driver.switch_to.default_content()

wait.until(EC.element_to_be_clickable((By.NAME, "email"))).send_keys("username")

wait.until(EC.element_to_be_clickable((By.NAME,"password"))).send_keys("****")  

wait.until(EC.element_to_be_clickable((By.ID,"submitBtn"))).click()

wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'div.ct-breadcrumb')))

try:
    wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,"wiz-iframe-intent")))
    wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div.close-btn.js-close-popup>button"))).click()
except:
    pass

driver.switch_to.default_content()  
action.move_to_element(driver.find_element_by_css_selector("div.sidebar__brand+ul>li:first-child>a")).perform()

wait.until(EC.visibility_of_element_located((By.LINK_TEXT, "All Boards")))  

wait.until(EC.element_to_be_clickable((By.LINK_TEXT,"All Boards"))).click()

wait.until(EC.element_to_be_clickable((By.LINK_TEXT,"pe-funnel"))).click()

wait.until(EC.visibility_of_element_located((By.XPATH, "//*[name()='tspan' and contains(@stroke-linejoin,'round')]"))) 

all_data = driver.find_elements_by_xpath("//*[name()='tspan' and contains(@stroke-linejoin,'round')]")

print(len(all_data))

for data in all_data:
 print(data.text)
Sign up to request clarification or add additional context in comments.

3 Comments

due to new functionalities of clevertap the last two lines are giving error.
Can you raise a new ticket for the same ?

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.