Found 871 Articles for Automation Testing

How to install Selenium package in Anaconda?

Debomita Bhattacharjee
Updated on 08-Apr-2021 08:01:25

5K+ Views

We can install the Selenium package in Anaconda. The conda has multiple packages so that it can be integrated with Selenium, Selenium-pytest, and so on from the below link − https://anaconda.org/searchA conda is a command line tool in the form of a package which is used for Anaconda.It has some similarities with pip. Selenium is present within the community based conda-forge channel available from the below link − https://anaconda.org/conda-forge/seleniumTo complete installation of this package, we can execute any of the below commands −conda install -c conda-forge seleniumconda install -c conda-forge/label/gcc7 seleniumconda install -c conda-forge/label/cf201901 seleniumconda install -c conda-forge/label/cf202003 seleniumRead More

How to get the following-sibling element for a table type of structure in Selenium?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:55:10

2K+ Views

We can get the following-sibling element for a table type of structure in Selenium webdriver. A following-sibling is used to determine the siblings of the context node.Also, these siblings should be present at the same hierarchy of the current node and share the same parent. Let us take an instance of a table with table tag having multiple children with tag tr.Then let us try to identify the elements in the third row highlighted on the below image from the first row which contains the table headers.Syntax//table[@id='table1']/tbody/tr[1]/following-sibling::tr[2]/tdHere, we are locating the third row in the table, but we have provided ... Read More

How to handle chrome notification in Selenium?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:52:08

5K+ Views

We can handle Chrome notification in Selenium webdriver. These are generally known as the web push notifications and can be handled with the help of the ChromeOptions class. The below image shows a notification from the browser Chrome −We have to create an object of this ChromeOptions class and apply the addArguments method on it. The parameter --disable-notifications is passed as a parameter to this method. Finally, this information is sent to the ChromeDriver.SyntaxChromeOptions o = new ChromeOptions(); o.addArguments("--disable-notifications");Exampleimport org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import org.openqa.selenium.WebDriver; public class NotificationChrome {    public static void main(String[] args) throws IOException {   ... Read More

How to read test data from an excel sheet and use it to test facebook login in Selenium Webdriver?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:47:53

900 Views

We can read test data from an excel sheet and use it to test Facebook login with Selenium webdriver in Python. We can access excel with Python with the help of the OpenPyXL library.To install this library, we have to run the command - pip install openpyxl. Besides, we have to add the statement import openpyxl in our code. To start with, we have to load the excel workbook with the help of the load_workbook method.The path of the workbook is passed as a parameter to this method. Then we have to determine its active sheet by applying the sheet ... Read More

How can we read data from an excel sheet in Selenium Webdriver?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:47:25

2K+ Views

We can read data from an excel sheet in Selenium webdriver in Python.An excel workbook consists of multiple sheets and each sheet consists of cells and columns.To work with excel in Python(with extension .xlsx, .xlsm, and so on) we have to utilize the OpenPyXL library. To install this package, we have to run the command: pip install openpyxl. Also, we have to add the statement import openpyxl in our code.To open an excel workbook, the method is load_workbook and pass the path of the excel file as a parameter to this method. To identify the active sheet, we have to ... Read More

Screenshot of a particular element with Python Selenium in Linux

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:45:08

477 Views

We can capture a screenshot of a particular element with Selenium webdriver in Python. To achieve this task, first we have to identify the element which we want to identify with the help of any locators like id, xpath, css, name, class name, tagname, link text or partial link text.After the element has been identified, we can capture its screenshot with the help of the screenshot method. We have to pass the file name where the screenshot shall be stored (along with extension) as a parameter to this methodSyntaxm=driver.find_element_by_tag_name("h4") m.screenshot("logo.png")Let us capture the screenshot of the highlighted text below −Examplefrom ... Read More

Error:selenium.common.exceptions.WebDriverException: Message: 'chromedriver' executable needs to be in PATH using Selenium

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:44:22

2K+ Views

We can get the error selenium.common.exceptions.WebDriverException if the path of the chromedriver.exe executable file is not set properly or incorrect within the webdriver.Chrome(). The below image shows such an exception.It can be resolved by the following ways −Verify the path of the chromedriver.exe file set within webdriver.Chrome.Install the webdriver manager with the command: pip install webdrivermanager. Then add the statement: from webdriver_manager.chrome import ChromeDriverManager in our code.ExampleCode Implementation with webdriver managerfrom selenium import webdriver from webdriver_manager.chrome import ChromeDriverManager #configure webdriver manager driver = webdriver.Chrome(ChromeDriverManager().install()) driver.implicitly_wait(0.5) #launch URL driver.get("https://www.tutorialspoint.com/index.htm") print("URL is: ") print(driver.current_url) driver.close()OutputRead More

How does Selenium Webdriver handle the SSL certificate in Safari?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:43:55

287 Views

Selenium webdriver is capable of handling SSL certificate in the Safari browser. This is done with the help of the DesiredCapabilities class. We shall create an object of this class. Then apply the setCapability method on it and set the value of property CapabilityType.ACCEPT_SSL_CERTS to true.The SSL is a protocol developed to have a secure connection between the server and the client browser. It verifies the website authenticity before any further communication with it.SyntaxDesiredCapabilities pc = DesiredCapabilities.safari(); pc.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.safari.SafariDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.remote.DesiredCapabilities; public class SSLErrorSafari{    public static void main(String[] args) { ... Read More

How to search for a keyword in google using Selenium Java?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:40:35

4K+ Views

We can search for a keyword in Google using Selenium webdriver in Java.In order, to perform a search, we have to first land on the Google page with the help of the get method.Then identify the search edit box with the help of any of the locators like id, name, class, xpath, tagname, or css. Then enter the keyword in the search box with the help of the sendKeys method.Finally, perform the keyword search by simulating ENTER keypress. This is done by using the sendKeys method and passing the parameter Keys.ENTER or Keys.RETURN.SyntaxWebElement r = driver.findElement(By.className("q")); r.sendKeys("Cypress"); r.sendKeys(Keys.RETURN);Exampleimport org.openqa.selenium.By; import ... Read More

How to Select date from a datepicker with Selenium Webdriver using Python?

Debomita Bhattacharjee
Updated on 08-Apr-2021 07:40:10

8K+ Views

We can select a date from a datepicker with Selenium webdriver using Python. To identify a particular date, first we have to use the find_elements method and identify all the dates having a common locator value.The find_elements returns a list of matching elements. We have to iterate through this list and search for the date which meets our criteria. Once we get that date, we would select it. Then break out from this iteration.Examplefrom selenium import webdriver #set chromodriver.exe path driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) #launch URL driver.get("https://jqueryui.com/datepicker/") #switch to frame l = driver.find_element_by_xpath("//iframe[@class='demo-frame']") driver.switch_to.frame(l); #identify element inside frame d= driver.find_element_by_id("datepicker") ... Read More

Advertisements