Home > OS >  How to adjust the layout area (the container inside the window) in selenium?
How to adjust the layout area (the container inside the window) in selenium?

Time:01-18

I am writing code in python using selenium. In the website tradingview, I wish to change the height of the bottom window (or container whatever you would like to call). The current height is 358px located inside the div id="bottom-area". Is it possible to write a python code to re-adjust the height to let say 200px?

enter image description here

links: https://www.tradingview.com/chart/MZSP38tx/?symbol=BINANCE:BTCUSDT (You probably need to have an account to see the link)

CodePudding user response:

We can change the style of an element using javascript

element = driver.find_element(By.CSS_SELECTOR, "#bottom-area")
value = '200px'
driver.execute_script("arguments[0].style.height = arguments[1]", element, value)

In general, you can change a generic attribute of an element (for example opacity) with this command

driver.execute_script("arguments[0].setAttribute('opacity',arguments[1])", element, value)
  • Related