0

Javascript inside html changes to class name based on hover. Because of that I can not click on the object.

Please check here to see my html code and object image

what I try so far:

select_project = WebDriverWait(driver, 2).until(
    EC.presence_of_element_located((By.XPATH ,"//a[@class='smalltextnolink']")))
select_project.click()

and

select_project = driver.find_element_by_xpath("//div/table/tbody/tr/td[2]")
select_project.click()
mtkilic
  • 1,213
  • 1
  • 12
  • 28

3 Answers3

0

Try selecting by CSS partial match.

select_project = WebDriverWait(driver, 2).until(EC.presence_of_element_located((By.CSS_SELECTOR, 'a[class^="smalltext"]')))
select_project.click()
Dalvenjia
  • 1,953
  • 1
  • 12
  • 16
0

Try using following CSS selector:

[onmouseover*='smalltextul']
0

How about adding tag into the xpath:

select_project = driver.find_element_by_xpath("//div/table/tbody/tr/td[2]/a")

select_project.click()

Another option I think about is considering them as 2 different elements if you really want to locate them by class:

Keep the button hovered: Is there a way to perform a mouseover (hover over an element) using Selenium and Python bindings?

firefox = webdriver.Firefox()
firefox.get('http://foo.bar')
element_to_hover_over = firefox.find_element_by_id("baz")
hover = ActionChains(firefox).move_to_element(element_to_hover_over)
hover.perform()

Then find the element with new class and perform the click

Tony Bui
  • 815
  • 5
  • 7