File tree Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Expand file tree Collapse file tree 3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change 3333 - Add or modify existing cookies.
3434 - Retrieve current user agent.
3535 - Check Existence of an element on the page.
36+ - Execute JavaScript statment.
3637- Element Parser
3738 - table Information.
3839 - Retrieve dropdown options in the dictionary.
Original file line number Diff line number Diff line change 1818 hide_show_elements ,
1919 is_element ,
2020 page_source ,
21+ run_js ,
2122 set_cookies ,
2223 take_screenshot ,
2324 visit ,
@@ -159,6 +160,7 @@ def _load_methods(self):
159160 self .is_element = partial (is_element , self .driver )
160161 self .set_cookies = partial (set_cookies , self .driver )
161162 self .ua = partial (get_user_agent , self .driver )
163+ self .js = partial (run_js , self .driver )
162164
163165
164166if __name__ == "__main__" :
Original file line number Diff line number Diff line change @@ -377,3 +377,20 @@ def get_user_agent(driver: webdriver) -> str:
377377 """
378378
379379 return driver .execute_script ("return navigator.userAgent" )
380+
381+
382+ def run_js (driver : webdriver , statement : str ) -> str :
383+ """Execute an javascript statement and return output
384+
385+ Args:
386+ driver (webdriver): selenium webdriver
387+ statement ([str]): and variable name or an statement to run
388+
389+ Returns:
390+ str: console output in str format
391+
392+ Example:
393+ Fetch URL
394+ >>run_js(driver,document.URL)
395+ """
396+ return driver .execute_script (f"return { statement } " )
You can’t perform that action at this time.
0 commit comments