Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 37 of 59

How to install Selenium in a conda environment?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 1K+ Views

We can install Selenium in a conda environment. The conda has multiple channels to find packages. We have to search for a package which is compatible with our operating system.All the packages shall be available in the link −https://anaconda.org/search?q=selenium&sort=ndownloads&sort_order=−1&reverse=trueOut of all the packages, the most popular and downloaded one is available in the link −https://anaconda.org/conda-forge/seleniumTo install this package, execute any one of the following commands −

Read More

How to open a link in new tab using Selenium WebDriver?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 10K+ Views

We can open a link in the new tab with Selenium. . The methods Keys.chord and sendKeys can be used for this. The Keys.chord method allows you to pass multiple keys simultaneously.We shall send Keys.CONTROL and Keys.ENTER as arguments to the Keys.chord method. Then the complete string is then passed as an argument to the sendKeys method. Finally, the sendKeys method has to be applied on the link which is identified by driver.findElement method.SyntaxString clicklnk = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.xpath("//*[text()='Privacy Policy']")). sendKeys(clicklnk);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 OpenInNwTab{    public static void main(String[] args) { ...

Read More

Clear text from textarea with selenium.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 2K+ Views

We can clear text from a text area with Selenium. We shall use the clear method to remove the content from a text area or an edit box. First we shall identify the text area with the help of any locator.A text area is identified with textarea tagname in the html code. Let us input some text inside the below text area, then clear the text.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class TextAreaClear{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       driver.get("http://www.uitestpractice.com/Students/Form"); ...

Read More

How to install Selenium WebDriver on Mac OS?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 3K+ Views

We can install Selenium on Mac OS. We shall take the help of Homebrew package manager for installation in Mac OS. Let us follow the step by step process −Install Selenium by running the command −pip install seleniumInstall the Chrome driver with the homebrew by running the command −brew cask install chromedriverVerify the version of the Chrome driver, by running the command −chromedriver −−versionCreate a test script and try to execute after save.from selenium import webdriver # driver initialization driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") # launch URL driver.get("https://www.tutorialspoint.com/index.htm")If the below error is triggered −unknown error: cannot find chrome binaryIt means the version ...

Read More

Switch tabs using Selenium WebDriver with Java.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 14K+ Views

We can switch tabs using Selenium. First we have to open a link in a new tab. The Keys.chord method along with sendKeys is to be used. The Keys.chord method allows you to pass more than one key at once. The group of keys or strings are passed as arguments to the method.We shall pass Keys.CONTROL and Keys.ENTER as arguments to the Keys.chord method. The whole string is then passed as an argument to the sendKeys method. Finally, the sendKeys method has to be applied on the link which is identified by driver.findElement method.SyntaxString clickl = Keys.chord(Keys.CONTROL, Keys.ENTER); driver.findElement(By.xpath("//*[text()='Terms of ...

Read More

Capturing browser logs with Selenium WebDriver using Java.

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 1K+ Views

We can capture browser logs with Selenium. We have to type cast the RemoteWebDriver to driver and then initialize it. Next, we have to use the setLogLevel method. The import org.openqa.selenium.remote.RemoteWebDriver statement needs to be added in code for the RemoteWebDriver.Syntax((RemoteWebDriver) driver).setLogLevel(Level.INFO);Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.remote.RemoteWebDriver import java.util.logging.Level; public class BrwLogs{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       // Enable logging with setLogLevel method       ((RemoteWebDriver) driver).setLogLevel(Level.INFO);       driver.get("https://www.tutorialspoint.com/index.htm");       ...

Read More

Why do we use WebDriver instead of Selenium IDE?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 492 Views

We can use webdriver instead of Selenium IDE. The Selenium IDE is a record and playback tool but not dependable. The web elements which are dynamic cannot be handled well with Selenium IDE.Selenium IDE can be used for an easy solution to automation, but for a full regression suite, Selenium webdriver should be used. Some of the differences between Selenium IDE and Selenium webdriver are −Sl. No.Selenium IDESelenium Webdriver1.It supports only Firefox.It supports all the major browsers.2.Simply a record and playback tool.Not a record and playback tool.3.Architecture based on Javascript.Architecture not based on Javascript. Communicates with browser applications.4.Does not support ...

Read More

How to wait for options in a select to be populated in Selenium?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 30-Nov-2020 3K+ Views

We can wait for options in a select tag to be populated with Selenium. This can be done with the explicit wait concept in synchronization. The explicit wait is designed on the expected condition for an element.To wait for the options, we shall verify if presenceOfNestedElementsLocatedBy is available within the explicit wait time. We shall implement the entire verification within the try catch block.Let us see if the options are available for selection in the Continents dropdown. The ExpectedCondition along with WebDriverWait is used for explicit wait.HTML code of the select dropdown.Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import ...

Read More

How do you use Selenium to execute javascript within a frame?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 28-Nov-2020 782 Views

We can use Javascript within a frame with Selenium. It can run Javascript commands by the executeScript method. The command to be executed is passed as an argument to the method.Next, we have to return the values from the Javascript command with the return keyword. We have to take the help of the window.length command in Javascript to count the number of frames in a page.SyntaxJavascriptExecutor j = (JavascriptExecutor) driver; int i = Integer.parseInt(j.executeScript("return window.length").toString());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; import org.openqa.selenium.JavascriptExecutor; public class FramesJS{    public static void main(String[] args) {         ...

Read More

How to record a video in Selenium webdriver?

Debomita Bhattacharjee
Debomita Bhattacharjee
Updated on 28-Nov-2020 1K+ Views

We can record a video with Selenium. There is no default technique in Selenium to record videos. The videos can be captured in the below processes−ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar files need to be downloaded and saved within the project folder.Next, add the above two jars to the project Build path. Right-click on project−> Click on Properties−> Choose Java Build Path−> Click on the Libraries tab−> Click on Add External Jars−> Browser and select the ATUTestRecorder.jar and ATUReporter_Selenium_testNG.jar−> Click on Apply−> Click OK.Have a folder to hold the videos within the project.Example@BeforeMethod public void bmethod(Method m){    // format of the date ...

Read More
Showing 361–370 of 590 articles
« Prev 1 35 36 37 38 39 59 Next »
Advertisements