ericmckean / chromedriver

Automatically exported from code.google.com/p/chromedriver
0 stars 0 forks source link

Unable to luanch Chrome with Switch " –use-fake-​ui-for-med​ia-stream" , Anybody can help me? #810

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
See http://goo.gl/ll2FvQ for common issues.

Issue Description:
I am trying to automate a WebRTC (Real Time Communication) Application 
,designed on HTML5 and it runs on Chrome browser .
In this application i need to access and capture the input from the Microphone 
or Camera from web application.
When i click on capture button, chrome is showing info bar(a kind of popup 
alert) with “allow” and “deny” options., Since this info bar i cannot 
handle with Selenium web driver.

After doing some research i came, to know that, If i manually launch chrome 
browser from command line with a switch “--use-fake-ui-for-media-stream” 
chrome is allowing to access the camera without info bar.

Example: C:\Users\user>start chrome --use-fake-ui-for-media-stream

But if i try the same switch web driver script,i am still getting the info bar 
with same "allow" and "deny" options when my script try to enable camera or 
microphone.

how to suppress this info bar as it worked manual chrome browser launch from 
command line? 

Selenium Web Driver Code Snippet:
import java.io.IOException;
import java.net.URL;
import java.util.Arrays;
import org.openqa.selenium.By;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;
public class UseChromeSwitch {
public static void main(String[] args) throws IOException {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(“chrome.switches”,Arrays.asList(“--use-fake-ui-
for-media-stream”));
RemoteWebDriver driver1 = new RemoteWebDriver(new 
URL(“http://127.0.0.1:4444/wd/hub”), capabilities);
driver1.get(“http://www.html5rocks.com/en/tutorials/getusermedia/intro/”);
driver1.findElement(By.id(“capture-button”)).click();
}
}

Note: Before running above code you need to run the from command line:
java -Dwebdriver.chrome.driver=”C:\chromedriver.exe” -jar 
“C:\selenium-server-standalone-2.41.0.jar”

(Note: Using very latest Chrome Driver)
Note: Please try this on laptop which has built-in camera otherwise you cannot 
access the camera.

Original issue reported on code.google.com by rajendra...@gmail.com on 30 May 2014 at 8:52

GoogleCodeExporter commented 9 years ago

Original comment by samu...@chromium.org on 21 Feb 2015 at 12:18

GoogleCodeExporter commented 9 years ago
Please provide chrome switch through ChromeOptions and it is working fine
Chrome:41, ChromeDriver:2.14

Please find below code:
ChromeOptions options = new ChromeOptions();
options.addArguments("--use-fake-ui-for-media-stream");

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);

WebDriver driver = new RemoteWebDriver(new 
URL("http://localhost:4444/wd/hub"),capabilities);
driver.get("http://www.html5rocks.com/en/tutorials/getusermedia/intro");
driver.findElement(By.id("capture-button")).click()

Original comment by ssudunag...@chromium.org on 18 Mar 2015 at 7:31

GoogleCodeExporter commented 9 years ago

Original comment by ssudunag...@chromium.org on 26 Mar 2015 at 6:39