Debomita Bhattacharjee

Debomita Bhattacharjee

590 Articles Published

Articles by Debomita Bhattacharjee

Page 38 of 59

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 786 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

How do you focus on new windows with selenium ide?

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

We can focus on new windows with Selenium IDE. On clicking a link, a new tab or a window opens. After accessing the new window, we can close it and shift to the parent window.Click on a link with the below step. Visit site is the name of the link to be clicked.Select the window which opened on clicking the link.Add Event is the page title of the window opened on clicking the link. Now, we can perform actions on the new window.Close the new window with the below step.Step back to the parent window with the below step. The ...

Read More

Best practice to wait for a change with Selenium Webdriver?

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

The best practice to wait for a change in Selenium is to use the synchronization concept. The implicit and explicit waits can be used to handle a wait. The implicit is a global wait applied to every element on the page.The default value of implicit wait is 0. Also it is a dynamic wait, meaning if there is an implicit wait of 5 seconds and the element becomes available at the 3rd second, then the next step is executed immediately without waiting for the entire 5 seconds. Once the 5 seconds have elapsed, and if element is not found, a ...

Read More

How to deal with ModalDialog using selenium webdriver?

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

We can deal with modal dialog boxes with Selenium. A modal is just like a window that enforces the user to access it prior to going back to the actual page. It can be an authentication window as well.Let us work with the below modal dialog −Exampleimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class ModDialog{    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/Switchto");       // identify element and click       WebElement m = driver       .findElement(By.xpath("//button[contains(text(), ...

Read More

How can I consistently remove the default text from an input element with Selenium?

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

We can consistently remove the default text from an input element with Selenium. The clear method is used to remove the values currently present in an edit box or a text area.The Keys.chord method along with sendKeys can also 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.First of all, pass Keys.CONTROL and a as arguments to the Keys.chord method. The whole string is then passed as an argument to the sendKeys method. Last, we have to pass Keys.DELETE to the ...

Read More

How to close the pop up window in selenium running?

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

We can close the pop up window with Selenium. The getWindowHandles and getWindowHandle methods are used for the pop up window. To store all the window handles opened in a Set data structure, the getWindowHandles method is used.To store the window handle of the pop up in focus, the getWindowHandle method is used. To iterate over the window handles, the iterator method is used. By default, the Selenium driver has the control over the parent window.To switch the focus of the driver to the child pop up window, we can take the help of the switchTo().window method. The window handle ...

Read More

How do you check scroll position using selenium?

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

We can check scroll position using Selenium. To check the position we shall use the Javascript executor. We have to verify the value of the window.pageYOffset in the browser.While the URL is launched, the scroll is at the top the value of window.pageYOffset is 0. As we scroll to an element, the value of the window.pageYOffset shall be greater than 0.SyntaxJavascriptExecutor j = (JavascriptExecutor) driver; Long v = (Long) j.executeScript("return window.pageYOffset;");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 ScrollPosition{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); ...

Read More

How do you get selenium to recognize that a page loaded?

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

We can get Selenium to recognize that a page is loaded. We can set the implicit wait for this purpose. It shall make the driver to wait for a specific amount of time for an element to be available after page loaded.Syntaxdriver.manage().timeouts().implicitlyWait();After the page is loaded, we can also invoke Javascript method document.readyState and wait till complete is returned.SyntaxJavascriptExecutor js = (JavascriptExecutor)driver; js.executeScript("return document.readyState").toString().equals("complete");After this, verify if the URL matches the one we are looking for.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 Pageload{    public static void main(String[] args) {   ...

Read More
Showing 371–380 of 590 articles
« Prev 1 36 37 38 39 40 59 Next »
Advertisements