Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 32 of 59

How to check if Element exists in c# Selenium drivers?

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

We can check if element exists with Selenium webdriver in C#. This can be determined with the help of the FindElements method. It returns a list of elements which matches the locator passed as a parameter to that method.If there are no matching elements, an empty list is obtained. In case we have used the method FindElement instead of FindElements, NoSuchElementException will be thrown if there are no matching elements.For implementation we shall be using the NUnit framework.Exampleusing NUnit.Framework; using OpenQA.Selenium; using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Firefox; using System; using System.Collections.Generic; namespace NUnitTestProject1{    public class Tests{       String u ...

Read More

How to scroll to element with Selenium WebDriver using C#?

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

We can scroll to an element with Selenium webdriver in C#. This is done with the help of JavaScript Executor. Selenium can run JavaScript commands with the help of ExecuteScript method.The method scrollIntoView in JavaScript is used to perform the scrolling action and the value true is passed as a parameter to the method. This is then passed to the ExecuteScript method.Syntaxvar e = driver.FindElement(By.XPath("//*[text()='Careers']")); ((IJavaScriptExecutor)driver) .ExecuteScript("arguments[0].scrollIntoView(true);", e);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/index.htm";       IWebDriver ...

Read More

How to run Selenium tests in multiple browsers one after another from C# NUnit?

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

We can run Selenium tests in multiple browsers one after another from C# NUnit. This is done with the help of the Test Fixture concept. This is an attribute that identifies a class, step up and tear down methods.There are some rules to be followed for a class to have a fixture −It should not be of type abstract.There should be a default constructor for a non−parameterized fixture.The parameterized fixture should have a constructor.It can be publicly exported.Exampleusing NUnit.Framework; using OpenQA.Selenium using OpenQA.Selenium.Chrome; using OpenQA.Selenium.Firefox; using System; namespace NUnitTestProject1{    //Test Fixture declaration    [TestFixture(typeof(FirefoxDriver))]    [TestFixture(typeof(ChromeDriver))]    public class ...

Read More

Selenium versus BeautifulSoup for Web Scraping.

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

We can perform web scraping with Selenium webdriver and BeautifulSoup. Web Scraping is used to extract content from a page. In Python, it is achieved with the BeautifulSoup package.Let us scrap and get the below links on a page −Let us also see the html structure of the above links −Let us see how to do web scraping with BeautifulSoupTo install the required package for Beautifulsoup, we should run the below commands −pip install bs4 pip install requestsExamplefrom bs4 import BeautifulSoup import requests #get all response d=requests.get("https://www.tutorialspoint.com/about/about_careers.htm") #response content whole page in html format s = BeautifulSoup(d.content, 'html.parser') #access to ...

Read More

Wait for an Ajax call to complete with Selenium 2 WebDriver.

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

We can wait for an Ajax call to complete with Selenium webdriver. The determination of the load time of the page due to an Ajax response is a difficult task. This can be achieved with the help of synchronization concepts and wait methods in Selenium. Some of them are listed below −Implicit wait − It allows the web driver to wait for the time specified after which exception is thrown. This wait is applicable to all steps in the test.Syntaxdriver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);ExampleCode Implementation with implicit wait.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class AjaxImplWt{    public static ...

Read More

Start safari with extension using safariDriver in selenium.

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

We can start Safari with extension using SafariDriver in Selenium webdriver. Safari is a prominent browser and is provided by default by Apple devices. For Safari versions 10 and greater than 10, the safaridriver comes automatically and is not required to be installed separately.The location of the SafariDriver is: /usr/bin/safaridriver. Also, it must be remembered that to work with the Safari latest version, users should have the Apple machine. This is because the Apply no longer supports Safari on Windows (from 2012).If we are using an older version of Safari in the Apple machine, we have to turn on the ...

Read More

What's the relationship between Selenium RC and WebDriver?

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

There is a relationship between Selenium RC and Selenium webdriver. Prior to the introduction of Selenium webdriver, there was extensive usage of Selenium RC.Both the tools, supported automation tests to be executed in multiple browsers. Also, multiple programming languages can be used to implement the test cases. However, there are differences between them as listed below −FunctionalitiesSelenium RCSelenium WebdriverServerNeeds the server to trigger test execution.No need for the server to trigger test execution.Object OrientedNot much support from object oriented concepts.Majority of tests based on object oriented concepts.Dynamic LocatorsNo identification of elements with dynamic locators.Identification of elements with dynamic locators.AlertsNo support ...

Read More

Browser Plugin Testing With Selenium.

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

We can perform browser plugin testing with Selenium webdriver. We can have single or multiple extensions of the Chrome browser while we manually open the browser and work on it.However, while the Chrome browser is opened through Selenium webdriver, those extensions which are available to the local browser will not be available. To configure an extension, we have to obtain the .crx extension file of the extension.Then we have to add the extension to the Chrome browser which is launched by Selenium. To get all the extensions available to the browser type chrome://extensions on the browser address bar.To get add ...

Read More

How to maximize the browser window in Selenium WebDriver using C#?

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

We can maximize the browser window with Selenium webdriver in C#. This can be done with the help of the Maximize method. We shall launch the browser and then apply this method on the driver object.Syntaxdriver.Manage().Window.Maximize();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/index.htm";       IWebDriver d;       [SetUp]       public void Setup(){          //creating object of FirefoxDriver          d = new FirefoxDriver();       }   ...

Read More

How do I pass options to the Selenium Chrome driver using Python?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 28-Dec-2020 2K+ Views

We can pass options to the Selenium Chrome driver using Python. This can be with the help of the ChromeOptions and the DesiredCapabilities class. For the ChromeOptions, we have to create an object for that class.Then we shall take the help of the add_argument method and pass the option we want to send to the browser as a parameter to the method. Finally, this information must be given to the web driver.ExampleCode Implementation.from selenium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions #object of ChromeOptions op = webdriver.ChromeOptions() #add option op.add_argument('--enable-extensions') #pass option to webdriver object driver = webdriver.Chrome(chrome_options=op)We can ...

Read More
Showing 311–320 of 590 articles
« Prev 1 30 31 32 33 34 59 Next »
Advertisements