Found 206 Articles for Dynamic Programming

How to obtain the tagname of the parent element in Selenium webdriver?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:38:56

2K+ Views

We can obtain the tagname of the parent element in Selenium webdriver. First of all, we need to identify the child element with help of any of the locators like id, class, name, xpath, or CSS. Then we have to identify the parent with the findElement(By.xpath()) method.We can identify the parent from the child, by localizing it with the child and then passing (parent::*) as a parameter to the findElement(By.xpath()). Next, to get the tagname of the parent, we have to use the getTagName() method.Syntaxchild.findElement(By.xpath("parent::*"));Let us identify tagname of the parent of child element li in the below html code ... Read More

How to obtain the page title using Selenium webdriver?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:34:51

9K+ Views

We can obtain the page title using Selenium webdriver. The method getTitle() is used to obtain the present page title and then we can get the result in the console.Syntaxt = driver.getTitle();Let us find the title of the current page. We shall get About Careers at Tutorials Point – Tutorialspoint as output.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; public class PageTitle{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       //implicit wait       driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);       WebDriver driver = new ChromeDriver(); ... Read More

How to handle frames in Selenium Webdriver in Python?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:21:12

609 Views

We can handle frames in Selenium webdriver in Python. An iframe is identified with a tag in an html document. An iframe is an html document containing elements that reside inside another html document. Let us see an html document of a frame.The following methods help to switch between iframes −switch_to.frame(args) – The frame index is put as an argument to the method. The starting index of the iframe is 0.Syntaxdriver.switch_to.frame(0), switching to the first iframe.switch_to.frame(args) - The frame name or id is put as an argument to the method.Syntaxdriver.switch_to.frame("nm"), switching to the iframe with name nm.switch_to.frame(args) - The ... Read More

How to interact with hidden elements in Selenium Webdriver?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:19:22

12K+ Views

We can interact with hidden elements in Selenium Webdriver. The hidden elements are the ones that are present in the DOM but not visible on the page. Mostly the hidden elements are defined by the CSS property style="display:none;". In case an element is a part of the form tag, it can be hidden by setting the attribute type to the value hidden.Selenium by default cannot handle hidden elements and throws ElementNotVisibleException while working with them. Javascript Executor is used to handle hidden elements on the page. Selenium runs the Javascript commands with the executeScript method. The commands to be run ... Read More

How to get an attribute value of an element in Selenium Webdriver?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:15:19

6K+ Views

We can get an attribute value of an element in the Selenium Webdriver. This is achieved with the help of the getAttribute method. In an html document, each element is identified with its tagname along with the element attributes with their values. To get an attribute value, we have to pass the element attribute as an argument to the getAttribute method.Let us see the html code of an element and obtain the value of its src attribute. The value of its src attribute shall be /about/images/logo.png.ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.Keys; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; public class ... Read More

How to upload files using Selenium Webdriver?

Debomita Bhattacharjee
Updated on 22-Nov-2021 11:00:22

4K+ Views

We can upload files using Selenium Webdriver. This is achieved by the sendKeys method. We have to first identify the element which performs the file selection by mentioning the file path [to be uploaded].This is only applied to an element having a type attribute set to file as a value along with the element tag name as input. The below html code shows the element with type = file value set.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; public class WndsFileUpl{    public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver",       "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");   ... Read More

Selenium WebDriver With Java Quickstart.

Debomita Bhattacharjee
Updated on 22-Nov-2021 10:56:04

381 Views

We can work with Selenium webdriver with Java Quickstart template. This can be done by following the below steps −Step1− Click on the File menu in Eclipse. Then select the option New. Next click on Other.Step2− Click on Maven Project from the Maven folder. Then click on Next.Step3− Proceed with the further steps.Step4− Select maven-archetype-quickstart template. Then click on Next.Step5− Add GroupId as Selenium, Artifact Id as Automation-Selenium, and proceed.Step6− A project should get created with an archetype project structure. The Selenium-related scripts should be written within the src/test/java folder.

How to execute a Javascript using Selenium in Python?

Debomita Bhattacharjee
Updated on 22-Nov-2021 10:48:51

20K+ Views

We can run Javascript in Selenium webdriver with Python. The Document Object Model communicates with the elements on the page with the help of Javascript. Selenium executes the Javascript commands by taking the help of the execute_script method. The commands to be executed are passed as arguments to the method.Some operations like scrolling down in a page cannot be performed by Selenium methods directly. This is achieved with the help of the Javascript Executor. The window.scrollTo method is used to perform scrolling operation. The pixels to be scrolled horizontally along the x-axis and pixels to be scrolled vertically along the ... Read More

How to run tests using a test runner file for Cucumber?

Debomita Bhattacharjee
Updated on 22-Nov-2021 10:45:09

13K+ Views

We can run tests using a test runner file for Cucumber. The test runner file should contain the path of the feature file and step definition file that we want to execute.Code Implementation of the Feature fileFeature − Login ModuleScenario − Welcome Page Login verificationGiven User is on Welcome PageThen Welcome page should be displayedExampleCode Implementation of step definition filepackage stepDefinations; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; public class stepDefination {    @Given("^User is on Welcome Page$")    public void user_on_welcome_page() {       System.out.println("User on welcome page");    }    @Then("^Welcome page should be displayed$")    public void verify_user_on_welcome_page() {   ... Read More

How to create a test runner file for Cucumber in Java?

Debomita Bhattacharjee
Updated on 22-Nov-2021 10:41:14

4K+ Views

We can create a test runner file for Cucumber. This can be done using the below steps −Step1− Click on the File menu in Eclipse. Then select the option New. Next click on Other.Step2− Click on Maven Project from the Maven folder. Then click on Next.Step3− Proceed with the further steps.Step4− Select maven-archetype-quickstart template. Then click on Next.Step5− Add GroupId as Automation, Artifact Id as Cucumber, and proceed.Step6− A project should get created with a Cucumber-type project structure. The Cucumber-related scripts should be written within the src/test/java folder.Step7− Create a new package called cucumberOptions inside the src/test/java folder.Step8− Create a ... Read More

Previous 1 ... 5 6 7 8 9 ... 21 Next
Advertisements