Found 871 Articles for Automation Testing

Running chrome browser in inconginto Mode in Selenium

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:51:03

12K+ Views

We can run Chrome browser Incognito mode with Selenium webdriver. Incognito mode is a safe mode of opening a browser. This can be done with the help of the DesiredCapabilities and ChromeOptions class.We shall create an object of the ChromeOptions class and apply addArguments method on it. Then pass −−incognito as a parameter to that method. We shall then create an object of the DesiredCapabilities class.We shall apply setCapability method on the object of the DesiredCapabilities class and pass the ChromeOptions.CAPABILITY and the object of ChromeOptions class as parameters to that method.Finally, this browser chrome profile shall be fed to ... Read More

How to deal with security certificates using Selenium?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:50:48

1K+ Views

We can deal with security certificates using Selenium webdriver. We can have certificates like the SSL certificate and insecure certificate. All these can be handled with the help of the DesiredCapabilities and ChromeOptions class.We shall create an object of the DesiredCapabilities class and apply setCapability method on it. Then pass the CapabilityType and value as parameters to that method.These general browser chrome profiles shall be fed to the object of the ChromeOptions class for the local browser with the help of the merge method. Finally, this information needs to be passed to the webdriver object.SyntaxDesiredCapabilities c=DesiredCapabilities.chrome(); c.setCapability(CapabilityType.ACCEPT_INSECURE_CERTS, true); c.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true); ... Read More

Why Selenium RC is deprecated?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:46:34

684 Views

Selenium RC is a key part in Selenium. It is a framework for testing that allows testers and developers to design test scripts in multiple languages to automate frontend UI test cases.It has a client library and a server that starts and quits the browser sessions by default.Selenium RC is deprecated because of the reasons listed below −Selenium RC comprises an additional layer of JavaScript known as the core which makes it slower.Selenium RC has complicated and redundant APIs.Selenium RC is not compatible with the HTMLUnit browser (required for headless execution).Selenium RC has in-built HTML report generation features for test ... Read More

How to get html with javascript rendered sourcecode by using Selenium?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:44:58

1K+ Views

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

Send keys without specifying element in Python Selenium webdriver

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:43:14

1K+ Views

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

Using Extensions with Selenium & Python

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:42:57

9K+ Views

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

Set Chrome's language using Selenium ChromeDriver

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:38:58

5K+ Views

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

How to fire javascript event in Selenium?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:37:50

1K+ Views

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

How to send keyboard shortcut ALT SHIFT z (hotkey) with Selenium2?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:36:05

2K+ Views

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

How do I send a DELETE keystroke to a text field using Selenium with Python?

Debomita Bhattacharjee
Updated on 02-Feb-2021 11:39:27

6K+ Views

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

Advertisements