The Pygorithm module is an educational module containing the implementation of various algorithms. The best use of this module is to get the code of an algorithm implemented using python. But it can also be used for actual programming where we can apply the various algorithms to a given data set.Finding the Data StructuresAfter installing the module in the python environment we can find the various data structures that is present in the package.Examplefrom pygorithm import data_structures help(data_structuresRunning the above code gives us the following result −OutputHelp on package pygorithm.data_structures in pygorithm: NAME pygorithm.data_structures - Collection of data structure ... Read More
We can disable images in Selenium Google chromedriver. The images are disabled so that page load is quicker and execution time is also less. In chromedriver, we have to configure the below browser parameter −profile.managed_default_content_settings.images, and set its value to 2.Syntaxp.put("profile.managed_default_content_settings.images", 2);Let’s try to disable images from the below page −ExampleCode Implementation.import org.openqa.selenium.By; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.HashMap; import java.util.Map; public class ImageDisable { public static void main(String[] args) throws IOException { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); Map p = new HashMap(); // browser setting to disable image p.put("profile.managed_default_content_settings.images", ... Read More
The os.path module is a very extensively used module that is handy when processing files from different places in the system. It is used for different purposes such as for merging, normalizing and retrieving path names in python . All of these functions accept either only bytes or only string objects as their parameters. Its results are specific to the OS on which it is being run.os.path.basenameThis function gives us the last part of the path which may be a folder or a file name. Please the difference in how the path is mentioned in Windows and Linux in terms ... Read More
Python can connect to oracle using a python package called cx_Oracle. Oracle is one of the famous and widely used database and python’s data processing features are leverages well using this connectivity. In this article we will see how we can connect to oracle database and query the DB.Installing cx_OracleWe can use the below command to install the python package which can be used for establishing the connectivity.Examplepip install cx_OracleConnecting to OracleNow using this module we can connect to a oracle database which is accessible through the oracle service name. We create a cursor and execute the SQl query through ... Read More
The netrc class in python is used to read the data from the .netrc file presnt in unix systems in user’s home firectory. These are hidden files containing user’s login credential details. This is helpful for tool slike ftp, curl etc to successfully read the ,netrc file and use it for their actions.The below program shows how we can read the .netrc file using python’s netrc module.Exampleimport netrc netrc = netrc.netrc() remoteHostName = "hostname" authTokens = netrc.authenticators(remoteHostName) # Print the access tokens print("Remote Host Name:%s" % (remoteHostName)) print("User Name at remote host:%s" % (authTokens[0])) print("Account Password:%s" % (authTokens[1])) print("Password for ... Read More
We can run a proxy with Selenium webdriver in Python. A proxy is an essential component to do localization testing. We can take an e-commerce application and check if the language and currency visible is as per the user location.With the help of proxy within tests, we can verify if the website user interface matches with the location. We have to SET a proxy with below steps −Import webdriver from Selenium package.Define proxy server address.Create an object of ChromeOptions classCommunication of proxy with ChromeOptions.Summing options to Chrome() object.ExampleCode Implementation.from selenium import webdriver #proxy server definition py = "128.21.0.0:8080" #configure ChromeOptions ... Read More
We can click on elements with an SVG using XPath in Selenium. The SVG element has the tag name svg. It has attributes like width, height, viewBox, and so on.To click the element with svg, we should identify the element then utilize the Actions class. We shall first move to that element with the moveToElement method and then apply the click method on it.Finally, to actually perform the action, we have to use the build and execute methods. To identify the svg element with xpath, there is the local-name() function available.Let us look at the html code of a svg ... Read More
Encoders and decoders for the External Data Representation (XDR). When we transport data between different external sources, this is the commonly used format that is used. It useful for creation and transfer of complex data structures. XDR provides a service associated with the OSI Presentation Layer.In the below program we see how the data is getting packed and unpacked using the xdrlib module.Exampleimport xdrlib p = xdrlib.Packer() print(type(p)) lst = [1, 2, 3] p.pack_list(lst, p.pack_int) print(p) u = xdrlib.Unpacker(p) print(type(u)) print(lst)Running the above code gives us the following result −Output [1, 2, 3]Read More
We can hide the Firefox window in Selenium webdriver. This can be done by making the browser headless. We shall achieve this with the FirefoxOptions class. We shall then create an object option of that class.We have to make the browser setting options.headless to True value. This driver object shall then receive this information. We need to have the import statement: from selenium.webdriver.firefox.options import Options as FirefoxOptions for adding the FirefoxOptions class.Syntaxoptions = webdriver.FirefoxOptions() options.headless = TrueExampleCode Implementation.from selenium import webdriver from selenium.webdriver.firefox.options import Options as FirefoxOptions #object of FirefoxOptions options = webdriver.FirefoxOptions() #setting headless parameter options.headless = True driver ... Read More
We can upload a file in Selenium with no text box. This is achieved with the help of the sendKeys method. It is applied on the web element which performs the task of selecting the path of the file to be uploaded.As we make an attempt to upload, we shall click on the Browse button. If we investigate the HTML code for this, we shall be able to locate the attribute type having the value file. Moreover, the file path to be uploaded should be accurate.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 FileUpload{ ... Read More