Found 719 Articles for Testing Tools

Find elements inside forms and iframe using Java and Selenium WebDriver.

Debomita Bhattacharjee
Updated on 18-Sep-2020 06:08:24

1K+ Views

We can find elements inside form and iframe with Selenium webdriver. A form in an html document is represented by atag. A form may contain multiple elements inside it. A form can be submitted with a submit() or a click() method.Let us see a form with fields email and password.Exampleimport 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 FormElements{    public static void main(String[] args) {  System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String url = "https://www.linkedin.com/";       driver.get(url);       driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);       // ... Read More

How to perform right click using Selenium ChromeDriver?

Debomita Bhattacharjee
Updated on 18-Sep-2020 05:36:00

539 Views

We can perform right click using Selenium ChromeDriver. On right clicking on a webelement, the context menu gets displayed. For example, if we right click on a text area, an additional menu with several options come up.Actions class in Selenium is responsible for simulating this mouse operation. The Actions class provides the contextClick() method to carry out this action and select any option from the context menu.To perform this entire operation, we shall first move the mouse to the middle of the element with moveToElement() method, then apply contextClick() method. Furthermore, we have to execute the build() method to execute the ... Read More

How to find specific lines in a table using Selenium?

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:27:12

3K+ Views

We can find specific lines in a table with Selenium webdriver. A table is identified in an html document with tag. Each table comprises a tag that represents rows and a tag to represent columns. To traverse through table rows and columns we use the method findElements().To count the total number of rows in table we use size() method available for list −List l=driver.findElements(By.tagName("tr")); int s= l.size();To count the total number of columns in table we use size() method available for list −List m=driver.findElements(By.tagName("td")); int t= m.size();Let us consider the below table and get the ... Read More

Clicking an element using javascript vs actions vs webdriver?

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:24:17

566 Views

We can click on an element using javascript, Actions class and webdriver methods. Selenium can execute commands in Javascript with the help of the execute_script() method.We have to import org.openqa.selenium.JavascriptExecutor in our code to work with a javascript executor. In order to click an element, first we have to move to that element with mouse movements. We can execute mouse movement with the help of the Actions class in Selenium.We have to use the moveToElement() method. This method shall perform mouse movement till the middle of the element and then perform click followed by build() and perform() methods. We have ... Read More

Find and click element by title Python Selenium.

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:21:15

17K+ Views

We can find and click elements by title in Selenium webdriver. An element can be identified with a title attribute with xpath or css selector. With the xpath, the expression should be //tagname[@title='value']. In css, the expression should be tagname[title='value'].Let us take an html code for an element with a title attribute.The xpath to identify the element should be //a[@title='Tutorialspoint'] and the css expression should be a[title='Tutorialspoint']. Once the element is identified we can use the click() method for clicking on it.ExampleCode Implementation.from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # implicit wait for 5 seconds driver.implicitly_wait(5) # maximize with ... Read More

How to wait until an element is present in Selenium?

Debomita Bhattacharjee
Updated on 15-Sep-2023 00:54:08

26K+ Views

We can wait until an element is present in Selenium Webdriver. This can be done with the help of synchronization concept. We have an explicit wait condition where we can pause or wait for an element before proceeding to the next step.The explicit wait waits for a specific amount of time before throwing an exception. To verify if an element is present, we can use the expected condition presenceOfElementLocated.ExampleCode Implementation.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; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; public class ElementPresenceWait{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");     ... Read More

Check if any alert exists using selenium with python.

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:13:17

3K+ Views

We can check if any alert exists with Selenium webdriver. An alert is designed on a webpage to notify users or to perform some actions on the alert. It is designed with the help of Javascript.An alert can be of three types – prompt, confirmation dialogue box or alert. Selenium has multiple APIs to handle alerts with an Alert interface. To check the presence of an alert we shall use the concept of explicit wait in synchronization.As we know, explicit wait is developed based on Expected condition for a specific element. For the alerts, we shall verify if alert_is_present exists ... Read More

How to click the 'Ok' button inside an alert window with a Selenium command?

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:10:21

4K+ Views

We can click the OK button inside an alert window with Selenium webdriver. An alert is designed on a webpage to notify users or to perform some actions on the alert. It is designed with the help of Javascript.An alert can be of three types – prompt, confirmation dialogue box or alert. Selenium has multiple APIs to handle alerts with an Alert interface. To click on the Ok button on alert, first of all we have to switch to alert with switchTo().alert() method.Next, to click on the Ok button, we have to use accept() method. Please note we cannot identify ... Read More

How to click a link whose href has a certain substring in Selenium?

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:08:50

2K+ Views

We can click a link whose href has a certain substring in the Selenium webdriver. There are multiple ways to perform this action. We can use find_element_by_partial_link_text() method to click on a link having a substring.The find_element_by_partial_link_text() method is used to identify an element by partially matching with the text within the anchor tag as specified in the method parameter. If there is no matching text, NoSuchElementException is thrown.Syntax −find_element_by_partial_link_text("Tutors")Also we can use css selector to identify the element whose href has a substring via * symbol. This is called wild character notation and implies that a string contains a certain ... Read More

Find next sibling element in Selenium, Python?

Debomita Bhattacharjee
Updated on 28-Aug-2020 13:05:43

11K+ Views

We can find a next sibling element from the same parent in Selenium webdriver. This is achieved with the help of xpath locator. It is important to note that it is only possible to traverse from current sibling to the next sibling with the help of xpath.To traverse to the next sibling, we have to use the following-sibling concept in xpath. This will allow us to traverse to the next sibling from the present sibling of the same parent.Syntax −driver.find_element_by_xpath("//div[@class='txt-bx']/following-sibling::p")Let us try to move from the first child of parent to the second as in the above image.ExampleCode ... Read More

Advertisements