Found 33676 Articles for Programming

What is the Background keyword in Cucumber?

Debomita Bhattacharjee
Updated on 18-Nov-2021 12:30:23

10K+ Views

The Background keyword is applied to replicate the same steps before all Scenarios within a Feature File.Background RulesLet us describe some of the rules while applying Background −It should be used for defining simple steps unless we are forced to bring the application to a state which requires complicated steps to be carried out. As requested by the stakeholders of the project.It should be brief and realistic.All the Scenarios should also be short and to the point.Background ExampleLet us see an example where we have used Background steps to be executed before all the tests in the Feature File. For ... Read More

What is Test Driven Development?

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

360 Views

Test-Driven Development is also known as the TDD. It consists of the below steps to be followed one-by-one −Step 1− Create a Test.Step 2− Verify if the test fails.If the test passes, create the second test.If the test fails, then move to Step 3.Step 3− Fix the test to make it pass.If the test passes, move to Step 4.If the test fails, then jump to Step 3.Step 4− Start code refractor and redo all the above steps till the development is done.Benefits of TDDThe benefits of TDD are listed below −The developer is required to apprehend the requirements to know ... Read More

Explain a Step Definition in SpecFlow.

Debomita Bhattacharjee
Updated on 18-Nov-2021 12:19:32

2K+ Views

To execute the Feature file, we must add the implementation logic for each of the steps. To add the definition of the step in SpecFlow, the C# language is used. Thus, a Step Definition File contains methods developed in C# within a Class.The methods have annotations along with a pattern to connect the Step Definition to every matching step. SpecFlow shall run the code to execute the keywords in Gherkin.A Step Definition file is a link between the application interface and Feature File. For providing readability features, the Step Definition File can have parameters. This signifies that it is not ... Read More

Explain a Feature file in SpecFlow.

Debomita Bhattacharjee
Updated on 18-Nov-2021 12:15:37

3K+ Views

The SpecFlow test execution begins from the Feature File. Here all the Features and their corresponding Scenarios are explained in plain text. It has a dual role of serving as an automation element as well as for documentation. A Feature File consists of one or more Scenarios in form of a list.Feature File CreationOnce a SpecFlow project is created, go to the Solution Explorer, and expand it.Right-click on the Features folder. Click on Add, then select the option New Item.Add New Item pop-up comes up. Type SpecFlow Feature in the search box. Select the option SpecFlow Feature File from the ... Read More

How to handle frame in WebDriver?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:51:05

352 Views

We can handle frames in Selenium webdriver. The frames in an html code are represented by the frames/iframe tag. Selenium can handle frames by switching the webdriver access from the main page to the frame.Methods to handle frames are listed below −driver.switch_to_frame("frame name") - frame name is the name of the frame.driver.switch_to_frame("framename.0.frame1") - used to access the subframe in a frame by separating the path with a dot. Here, it would point to the frame with the name frame1 which is the first sub-frame of the frame named framename.driver.switch_to_default_content() - used to switch the webdriver access from a frame to ... Read More

How can we handle authentication popup in Selenium WebDriver using Java?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:48:54

1K+ Views

We can handle authentication popup in Selenium webdriver using Java. To do this, we have to pass the user credentials within the URL. We shall have to add the username and password to the URL.Syntax −https://username:password@URL https://admin:admin@the-internet.herokuapp.com/basic_auth Here, the admin is the username and password. URL – www.the-internet.herokuapp.com/basic_auth Let us work and accept the below authentication popup.ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver;    public class AuthnPopup{       public static void main(String[] args) {       System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe");       WebDriver driver = new ChromeDriver();       String u = "admin";   ... Read More

How to scroll down a webpage in selenium using Java?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:43:33

777 Views

We can scroll down a webpage in Selenium using Java. Selenium is unable to handle scrolling directly. It takes the help of the Javascript Executor to perform the scrolling action up to an element.First of all, we have to locate the element up to which we have to scroll. Next, we shall use the Javascript Executor to run the Javascript commands. The method executeScript is used to run Javascript commands in Selenium. We shall take the help of the scrollIntoView method in Javascript and pass true as an argument to the method.Syntax −WebElement elm = driver.findElement(By.name("name")); ((JavascriptExecutor) driver) .executeScript("arguments[0].scrollIntoView(true);", elm);Exampleimport ... Read More

Get text using selenium web driver in python?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:41:05

561 Views

We can get text using Selenium webdriver in Python. This is done with the help of a text method. It fetches the text in an element that can be later validated.First, we need to identify the element with the help of any locators. Suppose we want to get the text - You are browsing the best resource for Online Education on the page below.ExampleCode Implementation.from selenium import webdriver driver = webdriver.Chrome (executable_path="C:\chromedriver.exe") # maximize with maximize_window() driver.maximize_window() driver.get("https://www.tutorialspoint.com/index.htm") # identify element l=driver.find_element_by_css_selector("h4") # get text and print print("Text is: " + l.text) driver.close()OutputRead More

How to use MSTest Annotations in specflow c#?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:37:49

643 Views

We can use MSTest annotations in SpecFlow C# in hooks. Hooks are event bindings to add more automation logic at certain steps. For example, for any step which is needed to be run before a specific Scenario. To introduce hooks in the code we have to add the [Binding] attribute.Hooks have global access. But it can be made available to Features and Scenarios by declaring a scoped binding. The scoped binding can be filtered with the tags.SpecFlow+ Runner LimitationsIf we are executing tests from more than one thread with SpecFlow+ Runner, the After and Before hooks like the BeforeTestRun and ... Read More

How to scroll the Page up or down in Selenium WebDriver using java?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:29:01

7K+ Views

We can scroll the page up or down in Selenium webdriver using Java. This is achieved with the help of the Actions class. First of all, we have to create an object of this Actions class and then apply the sendKeys method to it.Now, to scroll down a page, we have to pass the parameter Keys.PAGE_DOWN to this method. To again scroll up a page, we have to pass the parameter Keys.PAGE_UP to the sendKeys method. Finally, we have to use the build and perform methods to perform this action.Syntax −Actions a = new Actions(driver); //scroll down a page a.sendKeys(Keys.PAGE_DOWN).build().perform(); ... Read More

Advertisements