- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
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
Get PID of Browser launched by Selenium.
We can PID of browsers launched by Selenium webdriver. First of all, we have to create an object of the webdriver. Next, for example, to launch the browser in the Firefox browser, we have to take the help of webdriver.Firefox() class.
The location of the geckodriver.exe file is passed as a parameter to that class. This is done by setting the path to executable_path property. Then, the browser shall be launched with the get method.
Finally, to obtain the PID of the browser, we shall use the driver.service.process.id method.
Syntax
s = driver.service.process.pid
Example
from selenium import webdriver #path of geckodriver.exe driver = webdriver.Firefox(executable_path="C:\geckodriver.exe") #launch browser driver.get ("https://www.tutorialspoint.com/index.htm") #obtain PID of browser s = driver.service.process.pid print(s) #close browser driver.close()
Output
Advertisements