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 try the same with simple web driver script i am still getting
the info bar with same allow and deny options how to suppress this info bar as
it worked manual chrome browser launch from command line? :
here is my code:
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: Please try this on laptop which has built-in camera otherwise you cannot access the camera.
Thanks,
Rajendra
To view this discussion on the web visit https://groups.google.com/d/msgid/selenium-users/6f72731c-ea9d-44b8-82c5-78e79e329437%40googlegroups.com.