0

I've a python script (with selenium) where I can click a button:

button1 = driver.find_element_by_xpath("//*[@id='test1']")
button1.click()

When I run the script, it opens chrome + my app and it clicks on the button. After clicking on the button an image appears on the place of the button.

I can manually inspect this image:

<img style="" src="//files.qualifio.com/library/xxx.png" class="card_1">

Is there a way how I can get this src in Python after clicking my button1?

taras
  • 6,566
  • 10
  • 39
  • 50
DenCowboy
  • 13,884
  • 38
  • 114
  • 210

1 Answers1

1

after clicking on button, introduce webDriver wait to wait till image loads in DOM.

img = WebDriverWait(driver, 20).until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'img.card_1')))  
source = img.get_attribute("src")  
print(source)  

Note that, you will have to import :

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC 
cruisepandey
  • 28,520
  • 6
  • 20
  • 38