Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 31 of 59

Get PID of Browser launched by Selenium.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 3K+ Views

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.Syntaxs = driver.service.process.pidExamplefrom selenium import webdriver #path of geckodriver.exe driver = webdriver.Firefox(executable_path="C:\geckodriver.exe") #launch browser ...

Read More

How to start ChromeDriver in headless mode?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 1K+ Views

We can start chromedriver in headless mode. Headless execution is getting popular now−a−days since the resource consumption is less and execution is done at a faster speed.Post version 59, Chrome supports headless execution. ChromeOptions class is utilized to modify the default characteristics of the browser. The addArguments method of the ChromeOptions class is used for headless execution and headless is passed as a parameter to that method.SyntaxChromeOptions opt = new ChromeOptions(); opt.addArguments("headless"); WebDriver drv = new ChromeDriver(opt);Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.concurrent.TimeUnit; public class HeadlessChrome{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",     ...

Read More

How can I parse a website using Selenium and Beautifulsoup in python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 2K+ Views

We can parse a website using Selenium and Beautiful Soup in Python. Web Scraping is a concept used to extract content from the web pages, used extensively in Data Science and metrics preparation. In Python, it is achieved with the BeautifulSoup package.To have BeautifulSoup along with Selenium, we should run the command −pip install bs4 seleniumLet us scrap the below links appearing on the page −Then investigate the html structure of the above elements −Examplefrom selenium import webdriver from bs4 import BeautifulSoup #path of chromedriver.exe driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") #launch browser driver.get ("https://www.tutorialspoint.com/about/about_careers.htm") #content whole page in html format s ...

Read More

Running Selenium WebDriver python bindings in chrome.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 373 Views

We can run Selenium webdriver with Python bindings in Chrome. This can be done by downloading the chromedriver.exe file. Visit the link: https://chromedriver.chromium.org/downloads. There shall be links available for download for various chromedriver versions.Select the version which is compatible with the Chrome browser in the local system. Click on it. As the following page is navigated, select the zip file available for download for the operating system which is compatible with our local operating system.Once the zip file is downloaded, extract it and save the chromodriver.exe file at a location. To launch the Chrome, we have to add the statement from ...

Read More

How to check URL for 404 using Selenium WebDriver?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 3K+ Views

We can check the URL for 404 using Selenium webdriver. A 404 check is actually done to verify if there are broken links in a page. On clicking such a link, we shall not be directed to the correct page.A broken link can occur due to the following reasons −The landing page is no longer available.Some parts of the URL have been modified.An incorrect URL has been specified on the page.Firewall or geolocation limitations.A URL can have the following status code −5XX − Represents issue in server.4XX − Represents resource cannot be determined.3XX − Represents redirection.2XX − Represents correct condition.Thus ...

Read More

Use Selenium with Chromium Browser.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 7K+ Views

We can use Selenium with Chromium browser. Prior to working with Chrome with Selenium, we should have the Java JDK, a Java IDE and Selenium webdriver configured in our system. Then, we must download the chromodriver.exe file and set it up in our project with the below steps −Visit the link: https://chromedriver.chromium.org/downloads. There shall be links available for download for various chromedriver versions.Select the version which is compatible with the Chrome available to our system. Click on it. As the following page is navigated, select the zip file available for download for various operating systems (Linux, windows). Choose the one ...

Read More

Take screenshot of the options in dropdown in selenium c#.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 3K+ Views

We can take screenshots of the options in dropdown with Selenium Webdriver. A screenshot is generally captured for the failure test cases. This is achieved with the help of ITakesScreenshot interface.We shall take the help of GetScreenshot method to grab the screenshot. Finally, the SaveAsFile method is used where we pass the parameters – the path of the file and format of the image.Syntax((ITakesScreenshot)d). GetScreenshot().SaveAsFile("Screenshot.png", ScreenshotImageFormat.Png);For implementation we shall be using the NUnit framework.Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{    public class Tests{       String u ="https://www.tutorialspoint.com/selenium/selenium_automation_practice.htm";       IWebDriver d;     ...

Read More

How to connect to an already open browser using Selenium Webdriver?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 7K+ Views

We can connect to an already open browser using Selenium webdriver. This can be done using the Capabilities and ChromeOptions classes. The Capabilities class obtains the browser capabilities with the help of the getCapabilities method.This is generally used for debugging purposes when we have a large number of steps in a test and we do not want to repeat the same steps. First of all we shall launch the browser and enter some text in the below edit box.Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.Capabilities; import org.openqa.selenium.By; import java.util.Map; import java.util.concurrent.TimeUnit; public class ConnectBrwSession{    public static void main(String[] ...

Read More

Finding an element by partial id with Selenium in C#.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 2K+ Views

We can find an element by partial is with Selenium in C#. This can be done as we identify elements with the locator's CSS and xpath. The regular expression is used to find the partially matched element.Let us investigate the id attribute of an element having value as gsc−i−id1.In xpath, we utilize the contains() function for partial matching. So, here xpath expression shall be //*[contains(@id, 'id')]. This is because the subtext id is within the text gsc−i−id1. We can also take the help of the starts−with() function. So, the xpath expression becomes //*[starts−with(@id, 'gsc')] as the text gsc−i−id1 starts with ...

Read More

How to get all options in a drop-down list by Selenium WebDriver using C#?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Jan-2021 3K+ Views

We can get all options in a drop−down list by Selenium Webdriver in C#. The static drop−down in an html code is identified with a select tag. All the options for a drop−down have the option tag.To obtain all the options in the form of a list, we shall first identify that element with the help of any of the locators like id, xpath, name, and so on. Then we must create an object of the SelectElement class and apply Options method on it.Let us investigate the html code of drop−down.For implementation we shall be using the NUnit framework.Exampleusing NUnit.Framework; ...

Read More
Showing 301–310 of 590 articles
« Prev 1 29 30 31 32 33 59 Next »
Advertisements