Forums

Selenium Power BI

This Codes works perfectly on my own pc - but when i upload it here it does not. At the last browser.get i have printed the html to make sure it ends on the right site. I get no error message and it finds the right elements. On my own pc i use firefox driver. Could this be the issue? i Dont know how to debug to find out where the issue lies.

from selenium import webdriver
from selenium.webdriver.common.action_chains import ActionChains
from time import sleep
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless")
chrome_options.add_argument("--disable-gpu")

browser = webdriver.Chrome(options=chrome_options)

try:
browser.get('https://app.powerbi.com/?noSignUpCheck=1')

email = browser.find_element_by_xpath('//*[@id="i0116"]')
email.send_keys('USERNAME')

submit = browser.find_element_by_id('idSIButton9')
submit.click()
sleep(3)

password = browser.find_element_by_id('i0118')
password.send_keys('PASSWORD')

submit = browser.find_element_by_id('idSIButton9')
submit.click()
sleep(3)

no = browser.find_element_by_id('idBtn_Back')
no.click()
sleep(2)

browser.get('https://app.powerbi.com/groups/fd78c947-2a4b-4ce1-ae19-3699b4862f35')
sleep(3)
dataset = browser.find_elements_by_xpath('//*[@title="Production Dashboard"]')
sleep(1)
refresh = browser.find_elements_by_xpath('//*[@title="Refresh now"]')
sleep(1)
ActionChains(browser).move_to_element(dataset[1]).perform()
sleep(1)
refresh[0].click()

finally:
browser.quit()

Look at the content of the pages that you're getting with browser.get to see what is actually in the page. There will often be some indication there.

I fixed it - i just had to add sleep after my last click. The click was not registered as it immediately quit the browser after the click.

Ah, that would make sense. In our own Selenium tests we normally wait for the page to contain some specific element or text after clicking on things -- that's generally safer than sleeping, as it allows for times when thing take longer than expected.