Need help in retrieving values from script using python selenium. Few values are predefined and rest keeps on updating. Hope someone could help in retrieving the both. Tried few methods which gave no intended result.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
import unittest
import time
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.keys import Keys
options = webdriver.ChromeOptions()
options.add_argument("--start-maximized")
url = "https://demo.applitools.com/hackathonV2.html"
driver = webdriver.Chrome(chrome_options=options)
driver.get(url)
class Test(unittest.TestCase):
def test2(self):
element = driver.find_element_by_id("username")
element.send_keys("xxxx")
element1 = driver.find_element_by_id("password")
element1.send_keys("k")
element.send_keys(Keys.RETURN)
element= driver.find_element_by_xpath('//*[@id="showExpensesChart"]')
element.click()
element= driver.find_element_by_xpath('//*[@id="addDataset"]')
element.click()
#need to get the global var values(months, barchartdata)
c=driver.execute_script('return global')
if __name__=="__main__":
unittest.main()
Data to be retrieved : BarChartData,Data Updated values when "Show data for next year" is clicked.

JavaScriptso useJavaScriptto get it.jsonto convert to python's structure.<a>if value is in JavaScript. To get tag you can usedriver.find_elements_by_tag_name('a')and later you can get text or attributes from this tag.