4

I am using RSelenium on my EC2 server for several projects.
I am trying to set automatically the location in the parameters of my Firefox profile but I am not sure of where and how to include them.
I would assume somewhere in the makeFirefoxProfile function but I am not sure.

fprof <- makeFirefoxProfile(list("?"))

remDr <- remoteDriver(remoteServerAddr = "ec2-XX-XX-XXX-XX.eu-west-3.compute.amazonaws.com", port = 4445L, extraCapabilities = fprof)

remDr$open()

Any idea how this should be done ? Thanks!

[EDIT 1]: My Firefox profile information seems to be located in this folder: enter image description here

ML_Enthousiast
  • 709
  • 9
  • 26

2 Answers2

0

Try the following instead (it worked for me). I used the args extra capability to pass the profile directory to the driver:

remDr <- remoteDriver(remoteServerAddr = "ec2-XX-XX-XXX-XX.eu-west-3.compute.amazonaws.com", port = 4445L, extraCapabilities = list("args", "--profile /your/profile/directory"))
Bertold Kolics
  • 822
  • 6
  • 9
  • hi Bertold, I added some info on my post. I copied this whole profile folder into my server and updated location. But nothing changed, how can I actually know which info of location is within this Firefox profile directory? – ML_Enthousiast Sep 14 '20 at 10:41
  • Hi @ML_Enthousiast - when you execute the above command in R, it will echo back the location of the profile. Is it possible that Firefox profiles cannot be transferred between Windows and Linux images? Or is your AWS instance also running Windows? – Bertold Kolics Sep 14 '20 at 16:32
  • I have tried to place the local directory and then the root directory but for both I don't see a change. My AWS instance is running on Linux – ML_Enthousiast Sep 15 '20 at 06:39
  • Have you tried using a local instance? It may be possible to check how RSelenium invokes the gecko driver. – Bertold Kolics Sep 15 '20 at 14:28
0

Setting up the location automatically can be achieved easily using and ChromeDriver through for .

Chrome Devtools

Selenium 4 alpha versions have introduced to us the native support for Chrome DevTools Protocol through DevTools interface which helps us getting Chrome Development properties such as Application Cache, Fetch, Network, Performance, Profiler, Resource Timing, Security and Target CDP domains etc.

To set the location within Chrome Browsing Context you can use the following solution:

  • solution:

    import org.openqa.selenium.chrome.ChromeDriver;
    import org.openqa.selenium.devtools.DevTools;
    
    public void geoLocationTest(){
      ChromeDriver driver = new ChromeDriver();
      Map coordinates = new HashMap()
      {{
          put("latitude", 50.2334);
          put("longitude", 0.2334);
          put("accuracy", 1);
      }};    
      driver.executeCdpCommand("Emulation.setGeolocationOverride", coordinates);
      driver.get("ec2-XX-XX-XXX-XX.eu-west-3.compute.amazonaws.com");
    } 
    
DebanjanB
  • 118,661
  • 30
  • 168
  • 217