Creating a table in PostgreSQL is pretty straightforward. The syntax is −CREATE TABLE table_name( Column1_name type optional_constraint, Column2_name type optional_constraint, . . . ColumnN_name type optional constraint );If you want to make sure that your table is created only if it doesn’t already exist, you can specify that explicitly −CREATE TABLE IF NOT EXISTS table_name(…);An example of table creation is given below −CREATE TABLE marks( serial_no SERIAL PRIMARY KEY, name VARCHAR, roll_no INTEGER, marks_obtained INTEGER, perc_marks DOUBLE PRECISION, max_marks INTEGER, date_of_entry DATE );The above command will just ... Read More
We can get HTML with JavaScript rendered source code by using Selenium webdriver. Selenium can execute JavaScript commands with the help of the executeScript method.JavaScript command to be executed is passed as a parameter to the method. To obtain the HTML, with JavaScript, we shall pass return document.getElementsByTagName('html')[0].innerHTML as a parameter to the executeScript method.SyntaxJavascriptExecutor j = (JavascriptExecutor) driver; String s = (String) j.executeScript (return document.getElementsByTagName('html')[0].innerHTML");Exampleimport org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.JavascriptExecutor; import org.openqa.selenium.WebElement; import org.openqa.selenium.By; public class HTmlSrcJS{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); WebDriver driver = new ... Read More
We can send keys without specifying elements in Python with Selenium webdriver. The tagname input is used for all the edit boxes. We shall use the find_element_by_tag_name method and pass input as a parameter to that method.Thus we need not mention element attributes explicitly. Let us investigate the html code of an element which can be identified with tagname input.Examplefrom selenium import webdriver #set geckodriver.exe path driver = webdriver.Firefox(executable_path="C:\geckodriver.exe") driver.implicitly_wait(0.5) driver.get("https://www.tutorialspoint.com/index.htm") #identify element with tagname l = driver.find_element_by_tag_name("input") l.send_keys("Selenium") #obtain value obtained print("Value entered: ") print(l.get_attribute('value')) driver.quit()OutputRead More
We can use extensions with Selenium webdriver in Python. We can have multiple extensions of the Chrome browser while we manually open the browser and work on it.However, while the Chrome browser is opened through Selenium webdriver, those extensions which are available to the local browser will not be present. To configure an extension, we have to obtain the .crx extension file of the extension.Then we have to perform installation of the extension to the browser which is launched by Selenium. To get all the extensions available to the browser enter chrome://extensions on the browser address bar.To get add an ... Read More
Sometimes, some rogue queries can take too long to execute. If the queries are blocking in nature, i.e., they restrict access to a table while they are executing, then any other query on the same table will be put on hold, and this leads to a pile-up of queries. This can, depending on your DB load, even cause the max connections to be exceeded. Luckily, you can easily kill long queries in pgAdmin.Go to Dashboard in your pgAdmin. At the bottom, in the Server Activity section, under the Sessions Tab, you can see all the Active queries.Now, notice the cross ... Read More
Querying a DB in pgAdmin is quite straightforward. Locate your DB in the Servers dropdown on the left, and extend its dropdown, till you see the Schemas dropdown.Once you click on Schemas, the black button on the top, with the DB symbol and the play arrow will become clickable.Click on that button, and you will see a Query Tab open up. That’s it, you can type your queries for this particular DB in that box, and click the play arrow button to execute the queries.The output will be seen on the bottom, in the ‘Data Output’ section.Read More
We can send a DELETE keystroke to a text field using Selenium webdriver with Python. First of all, we have to identify the text field with the help of any locators like xpath, css, id, and so on.We can enter a text in the text field with the send_keys method. The value to be entered is passed as parameter to the method. To delete a key, we can pass Keys.BACKSPACE as a parameter to the send_keys method.Syntaxl = driver.find_element_by_id("gsc−i−id1") l.send_keys("Sel") l.send_keys(Keys.BACKSPACE)To delete all the keys entered simultaneously, we have to pass CTRL+A and BACKSPACE as parameters to the send_keys method.Syntaxl ... Read More
We can set Chrome browser language using Selenium webdriver. Some applications are designed such that it can be redesigned to multiple languages without any modifications. This is known as internationalization.In Selenium, we can modify the language preferences with the help of ChromeOptions class for the Chrome browser. We shall create an object of this class and apply addArguments method on it.To modify the language to Spanish, we have to pass −−lang=es as a parameter to the addArguments method. This information is then made available to the webdriver object.SyntaxChromeOptions opt = new ChromeOptions(); opt.addArguments("−−lang=es"); WebDriver drv = new ChromeDriver(opt);Exampleimport org.openqa.selenium.WebDriver; import ... Read More
We can fire JavaScript events in Selenium webdriver. Selenium can execute JavaScript events with the help of the JavaScript Executor. We shall pass the JavaScript commands as a parameter to the executeScript method.We shall fire the JavaScript event of clicking an element. First of all, we shall identify the element with the help of any of the locators like xpath, css, link text, and so on.We shall then pass argument [0].click() and webelement that shall be clicked as parameters to the executeScript method.SyntaxWebElement m = driver.findElement(By.linkText("Write for us")); JavascriptExecutor js = (JavascriptExecutor) driver; js.executeScript("arguments[0].click();", m);Let us make try to click ... Read More
We can send keyboard shortcut ALT SHIFT z(hotkey) with Selenium webdriver. This can be done with the help of the Keys class. We shall use the Keys.chord method and pass Keys.ALT, Keys.SHIFT and z as parameters to that method.The entire value obtained from the Keys.chord method is obtained as a String. That is then sent as a parameter to the sendKeys method.SyntaxString s = Keys.chord(Keys.ALT, Keys.SHIFT, "z"); driver.findElement(By.tagName("html")).sendKeys(s);ExampleCode Implementation with Keys.chord method.import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.Keys; import org.openqa.selenium.WebElement; import org.openqa.selenium.chrome.ChromeDriver; public class HtKeys{ public static void main(String[] args) { System.setProperty("webdriver.chrome.driver", "C:\Users\ghs6kor\Desktop\Java\chromedriver.exe"); ... Read More