1

enter image description hereenter image description hereWhat my code is trying to do is to find a set of elements then click on each element at which point a tooltip message is displayed. Click on a link in the tootip message which will take the user to a different page then do some activity there and navigate back to the previous page then click on the second element and click on the link in the tooltip message for the second element.

For some reason my code is only clicking on the link in the tool tip message for the second time. Next time its unable to find the link in the tooltip message to click on. Can someone please please help? I have tried different things but nothing worked. Please find below the code that I wrote:

I am using Python and Selenium

  elements = driver.find_elements_by_css_selector("#top-tables-chart-container > div > svg > g > g > rect")
  counter = 0
  for counter in range(counter, len(elements)):
          elements = driver.find_elements_by_css_selector("#top-tables-chart-container > div > svg > g > g > rect")
          webdriver.ActionChains(driver).move_to_element(elements[counter]).click().perform()
          time.sleep(5)
          tableNameLink= elements[counter].find_element_by_xpath("//div[@class='d3-tip bar-chart top-tables-tooltip n']//div[@class='left-section']//div[@class='table-name']//a[contains(@href,'#/table/')]")
          print tableNameLink
          tableNameLink.click()
          tableName = driver.find_element_by_xpath("//div[@class='discover-design-transform-container clearfix']//div[@class='left-header-section clearfix']//div[@class='entity-info table-type']//span[@class='entity-identifier']")
          table = tableName.text
          print " Table: " + table
          print '\n'

          if table == "lineitem":
            TableAccessFreqChartInfoBadgesValidation(self.driver).test_table_access_freq_chart_info_badges_validation("F","8","13","13")
            time.sleep(1)
            print '\n'

          if table == "orders":
              TableAccessFreqChartInfoBadgesValidation(self.driver).test_table_access_freq_chart_info_badges_validation("D","4","9","9")
              time.sleep(1)
              print '\n'
  topUsagePatternsTab = driver.find_element_by_xpath("//div[@id='workload-level-tabs']//a[@href='#/topUsagePatterns']")
  topUsagePatternsTab.click()
user3587233
  • 253
  • 1
  • 2
  • 13
  • Already answered here: http://stackoverflow.com/q/24775988/3124333 – SiKing Nov 04 '14 at 21:43
  • The "Table Name Link" elements that I need to click only loads when I hover my mouse over the each element that I am finding thru(elements = driver.find_elements_by_css_selector("#top-tables-chart-container > div > svg > g > g > rect")). So I am unable to find these links before I enter the for loop. Can you please help me fix my code? – user3587233 Nov 04 '14 at 22:28
  • Not without more information. Read this: https://stackoverflow.com/help/mcve – SiKing Nov 04 '14 at 22:35
  • So what I am doing is Login to my app and Click on a link(Top Usage Patterns) that takes me to a screen where there is a Chart(Screen shot1) that has different bar elements. I am hovering over each bar element to find a "Table Name link"(screen shot 2) for example "lineitem" on which I click and it takes me to a different page. Once validation is done on that page I click(Top Usage patterns) again where the chart is displayed and then I try to hover my mouse over the second element to find the second table name link element to click to continue validation. – user3587233 Nov 04 '14 at 22:53
  • I have added a bit more explaination and screen shots. I am very new to coding and new to this site so please bear with me. Thank you – user3587233 Nov 04 '14 at 22:54
  • @user3587233 thanks for the details. It is still not easy to help without not being able to reproduce it..is there a way to share your dashboard with us, or may be have the same dashboard as you do? – alecxe Nov 05 '14 at 12:39
  • Resolved the issue.. thanks much – user3587233 Nov 06 '14 at 15:19
  • Care to share how you solved this? It is perfectly fine to answer your own question: https://stackoverflow.com/help/self-answer – SiKing Nov 06 '14 at 16:28
  • Sorry, didn't see your message till now so the delay. But I found out that the issue was with our devlopment code where the Xpath expression that was finding the Table Name Link was returning more than 1 result as it was storing everything when we are navigating back n forth from that page to the next page. By solving that issue my problem was solved and the system was able to find the link and rest worked. – user3587233 Nov 10 '14 at 16:30

0 Answers0