Found 201 Articles for Dynamic Programming

How to handle frame in WebDriver?

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

253 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

Get text using selenium web driver in python?

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

435 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

444 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

6K+ 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

What is Stale Element Reference Exception in Selenium Webdriver & How To Fix It?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:25:24

1K+ Views

We may encounter StaleElementReferenceException while working with Selenium webdriver. We can fix the StaleElementReferenceException in the Selenium webdriver. The term stale means something which is not fresh and decayed. Thus a stale element points to an element that is not present anymore.There may be a case when an element was in DOM initially but after modifications in Document Object Model (DOM), the element becomes stale and the StaleElementReferenceException is thrown if we attempt to access this element.This exception is caused whenever an element is not present in the DOM or deleted. We can handle this exception in the following ways ... Read More

How can I manually set proxy settings in Python Selenium?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:18:52

1K+ Views

We can manually set proxy settings using Selenium webdriver in Python. It is done using the DesiredCapabilities class. We would create an object of this class and apply the add_to_capabilities method to it. Then pass the proxy capabilities as a parameter to this method.ExampleCode Implementationfrom selenium import webdriver from selenium.webdriver.common.proxy import ProxoxyType #add proxy’s ip and port p = '' pxy = Proxy() #set proxy type pxy.p_type = ProxyType.MANUAL #http proxy pxy.http_pxy = p #ssl proxy pxy.ssl_pxy = p #object of DesiredCapabilities c = webdriver.DesiredCapabilities.CHROME #set proxy browser capabilties pxy.add_to_capabilities(c) #set chromedriver.exe path ... Read More

How to use a specific chrome profile in selenium?

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

13K+ Views

We can use a specific Chrome profile in Selenium. This can be done with the help of the ChromeOptions class. We need to create an object of this class and then apply addArguments method on it.The path of the specific Chrome profile that we want to use is passed as a parameter to this method. We can open Chrome’s default profile with Selenium. To get the Chrome profile path, we need to input chrome://version/ in the Chrome browser and then press enter.Syntaxo = webdriver.ChromeOptions() o.add_argument = {'user-data-dir':'/Users/Application/Chrome/Default'}ExampleCode Implementationfrom selenium import webdriver #object of ChromeOptions class o = webdriver.ChromeOptions() #adding specific ... Read More

How do you automatically download a Pdf with Selenium Webdriver in Python?

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

2K+ Views

We can automatically download a pdf with the Selenium webdriver in Python. A file is downloaded in the default path set in the Chrome browser. However, we can modify the path of the downloaded file programmatically in Selenium.This is done with the help of the Options class. We have to create an object of this class and apply the add_experimental_option. We have to pass the parameters - prefs and the path where the pdf is to be downloaded to this method. Finally, this information has to be sent to the webdriver object.Syntaxop = Options() p = {"download.default_directory": "../pdf"} op.add_experimental_option("prefs", p)ExampleCode ... Read More

What is JSON parsing in Rest Assured?

Debomita Bhattacharjee
Updated on 18-Nov-2021 11:09:14

11K+ Views

We can parse JSON Response with Rest Assured. To parse a JSON body, we shall use the JSONPath class and utilize the methods of this class to obtain the value of a specific attribute.We shall first send a GET request via Postman on a mock API URL and observe the Response body.ExampleCode Implementationimport org.testng.annotations.Test; import static io.restassured.RestAssured.*; import io.restassured.RestAssured; import io.restassured.path.json.JsonPath; import io.restassured.response.Response; import io.restassured.response.ResponseBody; import io.restassured.specification.RequestSpecification; public class NewTest {    @Test    void responseParse() {       //base URI with Rest Assured class       RestAssured.baseURI = "https://run.mocky.io/v3";       //input details   ... Read More

How to validate XML response in Rest Assured?

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

6K+ Views

We can validate XML response in Rest Assured. For obtaining an XML response, we have to pass the parameter ContentType.XML to the accept method. We shall first send a GET request via Postman on a mock API URL.Using Rest Assured, we shall validate its XML Response containing the name of the subjects Rest Assured, Postman, and their prices 10 and 6 respectively.In the above XML Response, we shall obtain the values of the name and price tags by traversing the paths - courses.subject.name and courses.subject.price respectively.We shall perform the assertion with the help of the Hamcrest framework which uses the ... Read More

Advertisements