Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles on Trending Technologies
Technical articles with clear explanations and examples
Various Types of Keys in DBMS
The different types of keys in DBMS are −Candidate Key - The candidate keys in a table are defined as the set of keys that is minimal and can uniquely identify any data row in the table.Primary Key - The primary key is selected from one of the candidate keys and becomes the identifying key of a table. It can uniquely identify any data row of the table.Super Key - Super Key is the superset of primary key. The super key contains a set of attributes, including the primary key, which can uniquely identify any data row in the table.Composite Key - If ...
Read MoreFirst non-repeating character using one traversal of string in C++
In this tutorial, we are going to learn how to find the first non-repeating character in the given string. Let's see an example.Input −tutorialspointOutput −uLet's see the steps to solve the problem.Initialize the string.Initialize a map char and array to store the frequency of the characters in the string.Iterate over the string.Find the frequency of each character and store them in the map.Store the index of the character as well.Iterate over the character frequencies in the map.Print the first character with the frequency 1.ExampleLet's see the code.#include #include using namespace std; void findDistinctCharacters(string random_string) { // initializing ...
Read MoreHow do I pass options to the Selenium Chrome driver using Python?
We can pass options to the Selenium Chrome driver using Python. This can be with the help of the ChromeOptions and the DesiredCapabilities class. For the ChromeOptions, we have to create an object for that class.Then we shall take the help of the add_argument method and pass the option we want to send to the browser as a parameter to the method. Finally, this information must be given to the web driver.ExampleCode Implementation.from selenium import webdriver from selenium.webdriver.chrome.options import Options as ChromeOptions #object of ChromeOptions op = webdriver.ChromeOptions() #add option op.add_argument('--enable-extensions') #pass option to webdriver object driver = webdriver.Chrome(chrome_options=op)We can ...
Read MoreDownloading file to specified location with Selenium and python.
We can download files to a specified location with Selenium in Python. This is done by the help of the ChromeOptions class. We shall set the preferences of the browser and pass the download.default_directory parameter.We need to mention the path of the download directory with that parameter. This preference is sent to the ChromeOptions object with the add_experimental_option method.Finally, this browser information is shared with the driver object.Syntaxop = webdriver.ChromeOptions() p = ("download.default_directory": "C:\Users", "safebrowsing.enabled":"false") op.add_experimental_option("prefs", p) driver = webdriver.Chrome(chrome_options=op)ExampleCode Implementation.from selenium import webdriver from selenium.webdriver.common.by import By #object of ChromeOptions op = webdriver.ChromeOptions() #set download directory path p = ("download.default_directory": "C:\Users""safebrowsing.enabled":"false") ...
Read MoreHow to click Allow on Show Notifications popup using Selenium Webdriver?
We can click Allow on show notification pop-up in Selenium webdriver.These are messages from the website and often called as web push notification.This can be handled with the browser settings.This is done with the help of the ChromeOptions class. We shall create an object of it and apply the addArguments method on it. Then pass --disable-notifications as a parameter to the method.Finally, this information should be sent to the driver object.SyntaxChromeOptions p = new ChromeOptions(); p.addArguments("--disable-notifications");Let us try to handle the below notification on a page.ExampleCode Implementation.import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.chrome.ChromeOptions; import java.util.concurrent.TimeUnit; public class BrowserNotification{ public static void main(String[] args) ...
Read MoreHow to run selenium (Firefox) web driver without a GUI?
We can run Selenium (Firefox) webdriver without a GUI. This means that the execution has to be kicked in headless mode. The headless execution is popular now since it results in less consumption of resources.Firefox, without GUI, can be executed after we set the geckodriver path. We shall take the help of FirefoxOptions class, share this information to the browser via the setHeadless method. Finally pass true as a parameter to that.SyntaxFirefoxOptions op = new FirefoxOptions(); op.setHeadless(true); WebDriver driver = new FirefoxDriver(op);ExampleCode Implementation.import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebElement; import org.openqa.selenium.firefox.FirefoxDriver; import org.openqa.selenium.firefox.FirefoxOptions; import java.util.concurrent.TimeUnit; public class FirefoxNoGUI{ public static void main(String[] args) { ...
Read MoreHow to make firefox headless programmatically in Selenium with python?
We can make firefox headless programmatically in Selenium. This can be done with the help of the FirefoxOptions class. We shall then create an object option for that class.We shall set the parameter options.headless to True value. This information of the browser has to be passed to the driver object. We have to add the import statement: from selenium.webdriver.firefox.options import Options as FirefoxOptions for 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() #set options.headless to True options.headless = True driver = webdriver. Firefox(executable_path="C:\geckodriver.exe", options=options) driver.implicitly_wait(0.4) driver.get("https://www.tutorialspoint.com/index.htm") #identify ...
Read MoreHow can I control Chromedriver open window size?
We can control the chromedriver to open with a window size in Selenium. This is done with the help of ChromeOptions class. We have to create an object of that and apply addArguments method on it.Then pass window-size=x, y as a parameter to the method. The x and y are the dimensions of the window. Next, we have to apply this option to the Chrome browser with the DesiredCapabilities class. Finally, this information is sent to the driver object.SyntaxChromeOptions op = new ChromeOptions(); op.addArguments("window-size=500, 250"); DesiredCapabilities c = DesiredCapabilities.chrome(); c.setCapability(ChromeOptions.CAPABILITY, op); WebDriver d = new ChromeDriver(op);ExampleCode Implementation.import org.openqa.selenium.WebDriver; import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.chrome.ChromeDriver; import ...
Read MoreHow to upload file with selenium (Python)?
We can upload files with Selenium using Python. This can be done with the help of the send_keys method. First, we shall identify the element which does the task of selecting the file path that has to be uploaded.This feature is only applied to elements having the type attribute set to file. Also, the tagname of the element should be input. Let us investigate the html code of an element having the above properties.ExampleCode Implementation.from selenium import webdriver driver = webdriver.Chrome(executable_path="C:\chromedriver.exe") driver.implicitly_wait(0.5) driver.maximize_window() driver.get("https://www.tutorialspoint.com/selenium/selenium_automat ion_practice.htm") #to identify element s = driver.find_element_by_xpath("//input[@type='file']") #file path specified with send_keys s.send_keys("C:\Users\Pictures\Logo.jpg")Output
Read MoreFile Upload using Selenium WebDriver and Java Robot Class.
We can upload a file with Java Robot class in Selenium webdriver. It can produce simulationsfor the Keyboard and Mouse Event. It is derived from the AWT package.SyntaxRobot r = new Robot(); r.keyPress(KeyEvent.VK_ENTER); r.keyRelease(KeyEvent.VK_ENTER);ExampleCode Implementationimport org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import java.awt.*; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; import java.util.concurrent.TimeUnit; import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent; import org.openqa.selenium.JavascriptExecutor; public class RobotUplFile{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ChromeDriver(); driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS); driver.get("http://my.monsterindia.com/create_account.html"); // scroll to reach upload button JavascriptExecutor j = (JavascriptExecutor)driver; ...
Read More