Found 519 Articles for Selenium

Open New Browser Tab in Selenuim

Debomita Bhattacharjee
Updated on 29-Jun-2021 07:21:04

468 Views

Answer − We can open a new browser tab in Selenium webdriver. The methods - Keys.chord and sendKeys are required to achieve this task. The Keys.chord method is used to send multiple keys at once.We shall pass Keys.CONTROL and Keys.ENTER as parameters to this method. The complete string is again passed as a parameter to the sendKeys. Finally, the method sendKeys shall be applied on the link which we want to open in a new tabSyntaxString l = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.xpath("//*[text()='Links']")). sendKeys(l);Code Implementationimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import java.util.concurrent.TimeUnit; import org.openqa.selenium.Keys; public class OpenNewTab{    public static ... Read More

Selenium CSS Selectors Examples

Debomita Bhattacharjee
Updated on 25-Jun-2021 16:21:19

590 Views

 We can locate elements with locator CSS Selector in Selenium webdriver. The general expression to create a CSS expression is tagname[attribute='value']. We can utilize the id and class attributes to create a CSS.With id, the syntax of a CSS expression is tagname#id. For instance, for a CSS expression - input#txt-loc, input is the tagname and the txt-loc is the value of the id attribute.With class name, the syntax of a CSS expression is tagname.class. For instance, for a CSS expression - input.txt-cls, input is the tagname and the txt-cls is the value of the class attribute.If there are n sub-elements(children) ... Read More

What are the various Components of Selenium?

Debomita Bhattacharjee
Updated on 25-Jun-2021 16:20:15

4K+ Views

There are various components of Selenium. It can work on multiple browsers like Chrome, Firefox, Safari, and so on. It also supports more than one operating system like Windows, Mac, Linux, and so on.The components of Selenium are listed below −Selenium IDE.Selenium RC.Selenium Webdriver.Selenium Grid.Selenium IDESelenium Integrated Development Environment is an important part of the Selenium suite. It was first developed as a Firefox plugin, however now it is available in both Firefox and Chrome browser.Some of the features of Selenium IDE −The recording, debugging and editing of the functional tests can be done in Selenium IDE.The scripts in Selenium ... Read More

Difference between find Element and find Elements in Selenium

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:50:16

4K+ Views

There are differences between findElement and findElements method in Selenium webdriver. Both of them can be used to locate elements on a webpage. The findElement points to a single element, while the findElements method returns a list of matching elements.The return type of findElements is a list but the return type of findElement is a WebElement. If there is no matching element, a NoSuchElementException is thrown by the findElement, however an empty list is returned by the findElements method.A good usage of findElements method usage is counting the total number of images or accessing each of images by iterating with ... Read More

Does cypress support api automation testing also?

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:49:20

208 Views

Yes Cypress supports API automating testing also. XHR is known as the XML HTTP Request. It is an API which is used as an object. Its methods pass data between a server and browser. An XHR object can obtain data from a server in the form of a Response.Cypress can not only be used for UI automation, but can also be used to supervise the network traffic by directly acquiring the XHR objects. It is capable of mocking or stubbing a Response. An XHR information is obatined in the Network tab in the browser.XHR HeaderResponseTo trigger an XHR request, the ... Read More

Using the Selenium WebDriver - Unable to launch chrome browser on Mac

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:48:37

2K+ Views

While working with Selenium webdriver, we may be unable to launch the Chrome browser on Mac. However, it can be avoided by following the steps listed below −Step1 − Navigate to the link:https://sites.google.com/chromium.org/driver/ and click on the download link of the chromedriver version which is compatible with our local chrome browser.Step2 − Click on the chromedriver link available for the Mac operating system.Step3 − Once the download of the zip file gets completed, unzip it to get the chromedriver.exe file. Save it to a desired location.Step4 − While mentioning the path of the chromedriver.exe file in the System.setProperty method, we ... Read More

Is it possible to handle Windows based pop-ups in Selenium?

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:47:33

4K+ Views

Yes, it is possible to handle Windows based pop-ups in Selenium webdriver. Sometimes on clicking a link or a button, another window gets opened. It can be a pop up with information or an advertisement.The methods getWindowHandles and getWindowHandle are used to handle child windows. The getWindowHandles method stores all the handle ids of the opened windows in the form of Set data structure.The getWindowHandle method stores the handle id of the window in focus. Since the getWindowHandles method holds all the opened window handle ids, we can iterate through these handle ids with the iterator and next methods.To switch ... Read More

What is difference between Assert and Verify in Selenium?

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:45:55

3K+ Views

There are differences between Assert and Verify in Selenium. Both of these are used to verify if a webelement is available on the page. If the Assert fails, the test execution shall be stopped.The moment an Assertion has not passed in a step, the test steps after that step shall be hopped. However, this can be avoided by adding a try-catch block and incorporating the Assertion within this block.So the flow of the program execution continues if the Assertion yields a true condition. If not, the following steps after the failed step gets bypassed from the execution.To overcome this issue, ... Read More

Selenium - Element is not clickable at point

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:04:09

7K+ Views

We can get the error - Element is not clickable at point while trying to click a link in Selenium webdriver. This is common in chromedriver as the Chrome browser determines an element with point location.When the position of an element is changing and we make an attempt to click on it, this error is encountered. This is because the element is present in DOM, but its position is not fixed on the page.There are some workarounds to fix this error as listed below −Adding the explicit wait. The webdriver can wait till the expected condition - visibilityOf(webdriver shall wait ... Read More

How do I keep a session alive for long Selenium scripts in automation?

Debomita Bhattacharjee
Updated on 25-Jun-2021 13:00:32

4K+ Views

We can keep a session alive for long Selenium scripts in automation. In Chrome browser, this can be achieved with the help of the ChromeOptions and Capabilities classes.Capabilities class can get the capabilities of the browser by using the method – getCapabilities. This technique is generally used for debugging a particular step in a scenario having a sizable amount of steps.First, let us try to input text in the highlighted edit box in the below page −Code Implementationimport 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 BrwSessionAlive{    public static void main(String[] args) ... Read More

Previous 1 ... 7 8 9 10 11 ... 52 Next
Advertisements