Selenium and Chrome Driver issues
<p>I am carrying out some automated tasks and am required to run the script as root (for writing dirs to shares etc). The problem Im faced with is that chrome cant be run as root (for obvious reasons) so I have attempted various work arounds. The latest being an attempt to launch chrome using a normal users profile which by the looks of it doesnt actually launch the application as that user. </p>

<p>Is there a way to either launch the script as root and within the script launch chrome as a normal user or;</p>

<p>Lauch the script as a normal user and in the script execute the relevant commands as root? Specifically I need to execute <code>os.mkdirs</code>, <code>chmod</code> (this ive accomplished using subprocess) and finally I need to write files to the dirs using <code>with open...</code> (this is where the problem lies in this scenario).</p>

<p>Launching the script as root and attempting to execute chrome as a normal user was carried out as per below:</p>

<pre><code>options = webdriver.ChromeOptions()
options.add_agrument('PATH/TO/NORMAL/USER')
browser = webdriver.Chrome(chrome_options=options)
</code></pre>

<p>As suggested this doesnt seem to launch the application as the normal user but just uses the profile of the user. </p>

<p>How about using <code>os.setuid</code> to change user id?</p>

<p>Also, I haven't looked at it in detail, but the way this works might be of interest : <a href="https://github.com/ionelmc/python-su" rel="nofollow">https://github.com/ionelmc/python-su</a></p>

python google-chrome selenium