I have a function in Python:
def clickButtonViaText():
url = 'https://finance.yahoo.com/quote/AAPL/balance-sheet?p=AAPL'
options = Options()
options.add_argument('--headless')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get(url)
WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, '//button[@aria-label="Total Assets"]'))).click()
time.sleep(10)
soup = BeautifulSoup(driver.page_source, 'html.parser')
I want to add an argument to my function that takes a string and I want to pass the string in //button[@aria-label="Total Assets"]
as something like //button[@aria-label=str_variable]
where str_variable
is an argument passed with the function.
Example: def clickButtonViaText(str_variable):