Mobile emulation for responsive application testing - selenium-webdriver

I'm working on an web application that is responsive. I'm able to use the chrome mobile emulation option to launch the browser into the configuration I need. But since the Responsive is not set on Chrome options, I'm not getting the desired results.
Here is my code. According to the mobile Emulation option I can either use predefined device configurations or use device metrics to configure the resolution. But I would need to use the responsive option in chrome. How I can do this?
I mean to use the Responsive in the Device drop down
Map<String, Object> deviceMetrics = new HashMap<>();
deviceMetrics.put("width", 320);
deviceMetrics.put("height", 533);
Map<String, Object> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceMetrics", deviceMetrics);
ChromeOptions options = new ChromeOptions()
options.setExperimentalOption("mobileEmulation",mobileEmulation);

Related

Open App Settings tapping a Codename One Button

Is there any code that I can insert in the ActionListener of a Codename One Button to open the app settings on iPhone and on Android?
I saw something similar in other apps, for example to help the user to manually change the app permissions. In my case, I'd like to easily open the app settings to inspect the amount of total storage taken by the app (as suggested in https://stackoverflow.com/a/53992872/2670744) and other infos provided by Android and iOS.
I haven't tried this but execute("app-settings:") (from Display or CN) might work. If not you will need to use native code, specifically:
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
As mentioned here: How to open settings from my iPad application (Objective-C)

Not able to access mobile site even after changing the user-agent string in pc browser

hrmantra
is the site i want to view mobile view of. For which i have also changed my user-agent string in my pc's mozilla browser. I need this to be done, please help
You can use the Responsive Design Mode tool in Firefox to pick a mobile phone configuration or create a new one with custom settings. You can access this tool, as reported on the provided links:
From the Firefox menu: select "Responsive Design Mode" from the Web
Developer submenu in the Firefox Menu (or Tools menu if you display
the menu bar or are on OS X).
Picking a mobile device will automatically set the correct screen resolution, user-agent string and device pixel ratio (DPR).

Windows Popup appears while saving data in Chrome

I am creating some data and click on Save button. Manually when i do it there is no popup at all. But in automation browser of chrome i could see a popup appears asking to stay in page or leave page. How can i avoid the popup in automation script?
As per my knowledge, we have to create profile for chrome driver. I used the below whicc is not working for me. Can someone plssss plssss help me out on this
String userProfile= "C:\\Users\\user_name\\AppData\\Local\\Google\\Chrome\\User Data\\Default\\";
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir="+userProfile);
options.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com");
is there any specific reason that you are using ChormeOptions?
You can simply use the below code, and it'll work fine and no popups.
System.setProperty("webdriver.chrome.driver","pathToChromeDriver");
WebDriver driver = new ChromeDriver();
driver.get("http://www.google.com");

Profile setting of browser to be used with selenium webdriver

for mozila we use firefoxprofile class to deal with profile setting. I want to know ho do we deal with chrome and IE to set profile i.e. which do we use to deal with profile setting for IE or CHROME.
Anyone can help me out?
thank you..!!
With Firefox, we use Profiles.
With Chrome, we use Options.
eg:
ChromeOptions options = new ChromeOptions();
options.addArguments("--ignore-certificate-errors");
options.addArguments("--disable-popup-blocking");
options.addArguments("--disable-translate");
options.addArguments("--start-maximized");
With IE, we use Derired Capabilities.
eg:
DesiredCapabilities ieCapabilities = DesiredCapabilities.internetExplorer();
ieCapabilities.setCapability("unexpectedAlertBehaviour" , "ignore");

setVolume for html5 audio doesn't work on mobile Android or Safari - Any workaround?

So it seems like setVolume() for html5 audio doesn't work at all on both Android stock browser and Mobile Safari. Here's a test case.
Is there any further evidence to this, an open issue or perhaps even a workaround (apart from resorting to Flash for android)?
From the Safari HTML5 Audio and Video guide:
On iOS devices, the audio level is always under the user’s physical control. The volume property is not settable in JavaScript. Reading the volume property always returns 1.
On all other devices you can also set the muted property to true.
On Android you can set the volume property and it works in the native browser but not in Chrome.
Try this...
var audio1 = new Audio();
audio1.src = "test.mp3";
audio1.volume = 0.3;
audio1.play();

Resources