- Trending Categories
- Data Structure
- Operating System
- C Programming
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
print(driver.execute_script('return document.title')) print(driver.execute_script('return document.URL'))
javas = "document.getElementsByName('user-search').click();" driver.execute_script(javas)
Please note, we have used getElementsByName('user-search'). The functions like getElementsByName and getElementsById return an array of matching elements. So for locating the first element, the index is used. However if we are using getElementById function, we need not use the index since only one matching element is referred there.
userN= driver.find_element_by_id("user-search']") driver.execute_script("arguments.click();", userN)
print driver.execute_script('return document.title')
from selenium import webdriver #browser exposes an executable file #Through Selenium test we will invoke the executable file which will then #invoke #actual browser driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # to maximize the browser window driver.maximize_window() #get method to launch the URL driver.get("https://www.tutorialspoint.com/index.htm") #to refresh the browser driver.refresh() # get the title of page in console print(driver.execute_script('return document.title')) # get the URL of page in console print(driver.execute_script('return document.URL')) #to close the browser driver.close()
- How to get the title and URL of the page in Selenium with python?
- Get page title with Selenium WebDriver using Java.
- How to get screenshot of full webpage using Selenium and Java?
- How to get the complete screenshot of a page in Selenium with python?