Skip to content

Instantly share code, notes, and snippets.

View ShamaUgale's full-sized avatar

Shama Ugale ShamaUgale

View GitHub Profile
java -jar selenium-server-4.0.0-alpha-6.jar hub
java -jar selenium-server-4.0.0-alpha-6.jar standalone
package com.devtools;
import org.apache.commons.codec.binary.Base64;
import org.openqa.selenium.By;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.network.Network;
import org.openqa.selenium.devtools.network.model.Headers;
import java.util.HashMap;
import java.util.Map;
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.performance.Performance;
import org.openqa.selenium.devtools.performance.model.Metric;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.log.Log;
public class CaptureConsoleLogs {
private static ChromeDriver driver;
private static DevTools chromeDevTools;
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.network.Network;
import java.util.Optional;
public class CaptureNetworkTraffic {
@ShamaUgale
ShamaUgale / GeoMocking.java
Last active November 3, 2020 12:26
An example to demonstarte the geo location mocking with selenium 4
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.emulation.Emulation;
import org.openqa.selenium.devtools.network.model.ConnectionType;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
@ShamaUgale
ShamaUgale / SetDeviceOrientation.java
Created October 24, 2020 20:11
This is an example to simulate DeviceOrientation with devtools and selenium4
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.deviceorientation.DeviceOrientation;
public class SetDeviceOrientation {
final static String PROJECT_PATH = System.getProperty("user.dir");
@ShamaUgale
ShamaUgale / SetDeviceMode.java
Last active September 18, 2021 22:32
This is an example of setting the device mode with height width and scalefactor with devtools and selenium4
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.DevTools;
import java.util.HashMap;
import java.util.Map;
public class SetDeviceMode {
final static String PROJECT_PATH = System.getProperty("user.dir");
@ShamaUgale
ShamaUgale / SetUserAgent.java
Created October 24, 2020 20:08
This is an example to simulate the iPhone5 useragent with devtools and seleium 4
package com.devtools;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.devtools.Command;
import org.openqa.selenium.devtools.DevTools;
import org.openqa.selenium.devtools.emulation.Emulation;
import java.util.Optional;
public class SetUserAgent {