Posts

Showing posts from September, 2021

JavaScriptExecutor : Part-1

JavaScriptExecutor Before we discuss on JavaScriptExecutor, We will discuss what is JavaScript actually? So, What is JavaScript ? Java Script is an object-oriented programming language commonly used to create interactive effects within the web browser to Handle WebElements within Web Page. It is used by Selenium WebDriver to do handle WebElements. Now lets us discuss, What is JavaScriptExecutor? The JavaScriptExecutor is an interface that provides mechanisms to execute javascript through the Selenium Driver. To run JavaScript in the context of the currently selected frame or window, it provides two methods i.e. "executescript" and "executeAsyncScript" The basic advantage of JavaScriptExecutor is that Selenium provides a way to run Java Script in webdriver. Sometimes the locator can not work, in that case the JavaScriptExecutor will help interact with web elements on a particular webpage. The reason behind this is, even Selenium webdriver convert the bindings ...

Python Docstrings

Python Docstrings Python documentation strings (or docstrings) provide a convenient way of associating documentation with Python modules, functions, classes, and methods. It’s specified in source code that is used, like a comment, to document a specific segment of code. Unlike conventional source code comments, the docstring should describe what the function does, not how. How docstring look like? The doc string line should begin with a capital letter and end with a period. The first line should be a short description. If there are more lines in the documentation string, the second line should be blank, visually separating the summary from the rest of the description. The following lines should be one or more paragraphs describing the object’s calling conventions, its side effects, etc. Doc String can be one liner or multiliner based on requirements with proper indentation . Declaring Docstrings: The docstrings are declared using ”’triple single quotes”’ or “””triple double quotes””” j...

range() vs xrange() in Python:

 range() vs xrange() in Python: The range() and xrange() are two functions that could be used to iterate a certain number of times in for loops in Python.  In Python 3, there is no xrange , but the range function behaves like xrange in Python 2. If you want to write code that will run on both Python 2 and Python 3, you should use range(). range() – This returns a range object (a type of iterable). xrange() – This function returns the generator object that can be used to display numbers only by looping. The only particular range is displayed on demand and hence called "lazy evaluation". The points of comparison are:  Return Type: range() returns –  range  object.  xrange() returns –  xrange()  object. Example: a=range(5) print(type(a)) # O/P:  <type 'list'> x=xrange(6) print(type(x)) #O/P:  <type 'xrange'> Operation Usage: range() returns the list, all the operations that  can  be applied on the list can be used on i...

*args and **kwargs in Python

  What do you mean by *args and **kwargs in Python function? *args: *args is a special syntax used in the function definition to pass variable-length arguments. “*” means variable length and “args” is the name used by convention. You can use any other. **kwargs: **kwargs is a special syntax used in the function definition to pass variable-length keyworded arguments. Here, also, “kwargs” is used just by convention. You can use any other name. Keyworded argument means a variable that has a name when passed to a function. It is actually a dictionary of the variable names and its value. ========================================================================= Important Points related to *args & **kwargs: *args and **kwargs are special keyword which allows function to take variable length argument. *args passes variable number of non-keyworded arguments list and on which operation of the list can be performed. **kwargs passes variable number of keyword arguments dictionary to functi...

Python namespaces & LEGB rule in Python

Image
What are Python namespaces? What is the LEGB rule in Python? A namespace in Python ensures that object names in a program are unique and can be used without any conflict. Python implements these namespaces as dictionaries with 'name as key' mapped to a corresponding 'object as value'. This allows for multiple namespaces to use the same name and map it to a separate object. A few examples of namespaces are as follows: Local Namespace  includes local names inside a function. the namespace is temporarily created for a function call and gets cleared when the function returns. Global Namespace  includes names from various imported packages/ modules that are being used in the current project. This namespace is created when the package is imported in the script and lasts until the execution of the script. Built-in Namespace  includes built-in functions of core Python and built-in names for various types of exceptions. The  lifecycle of a namespace  depends upon the sco...

Dynamically typed language

What is a dynamically typed language? Before we understand a dynamically typed language, we should learn about what typing is. Typing refers to type-checking in programming languages.  In a strongly-typed language, such as Python, "3" + 2 will result in a type error since these languages don't allow for implicit conversion of data types.  On the other hand, a weakly-typed language like Java, C++, will simply output "32" as result. Type-checking can be done at two stages  Static - Data Types are checked before execution.  Dynamic - Data Types are checked during execution.  Python is an interpreted language, executes each statement line by line and thus type-checking is done on the fly, during execution. Hence, Python is a Dynamically Typed Language. Thanks for reading!!

About Git log

  Git log-Details  ❖ Git log is a utility tool to review and read a history of everything that happens to a repository. Multiple options can be used with a git log to make history more specific.  ❖ Generally, the git log is a record of commits. A git log contains the following data:  ➢ commit hash number which is a 40 character checksum data generated by the SHA (Secure Hash Algorithm) algorithm. It is a unique number.  ➢ Commit Author metadata: The information of authors such as author name and email.  ➢ Commit Date metadata: It's a date timestamp for the time of the commit.  ➢ Commit title/message: It is the overview of the commit given in the commit message. Different Commands of Git log: ➔ git log  ◆ Whenever you need to check the history, you have to use the git log command. The basic git log command will display the most recent commits and the status of the head.  ➔ git log --oneline  ◆ the --oneline git log to display:  ...