0

I have two files using Selenium to run different tasks.

I can run them separately(only one running), but if I want to run the two files no matter at the same time or run it one by one. The second one will crash with the following errors.

 File "site-packages\selenium\webdriver\chrome\webdriver.py", line 75, in __ini
__
 File "site-packages\selenium\webdriver\remote\webdriver.py", line 156, in __in
t__
 File "site-packages\selenium\webdriver\remote\webdriver.py", line 251, in star
_session
 File "site-packages\selenium\webdriver\remote\webdriver.py", line 320, in exec
te
 File "site-packages\selenium\webdriver\remote\errorhandler.py", line 242, in c
eck_response
elenium.common.exceptions.WebDriverException: Message: unknown error: Chrome fa
led to start: crashed
 (unknown error: DevToolsActivePort file doesn't exist)
 (The process started from chrome location C:\Program Files (x86)\Google\Chrome
Application\chrome.exe is no longer running, so ChromeDriver is assuming that C
rome has crashed.)
 (Driver info: chromedriver=2.41.578737 (49da6702b16031c40d63e5618de03a32ff6c19
e),platform=Windows NT 6.1.7601 SP1 x86_64)

The code is quite simple like:

u = getpass.getuser()

chrome_options = Options()
## Add the user information
chrome_options.add_argument('user-data-dir=C:\\Users\\%s\\AppData\\Local\\Google\\Chrome\\User Data' % (u))

## SF Case page
source = "https://na66.salesforce.com/500?fcf=00BC0000008hfCI"
driver = webdriver.Chrome(chrome_options=chrome_options)
driver.get(source)

Any suggestions please?

Winnie-c
  • 179
  • 2
  • 13
  • How is `% (u)` defined? – undetected Selenium Sep 26 '18 at 07:47
  • @Newcontributor Modified the code. It is to get user. – Winnie-c Sep 27 '18 at 01:35
  • You need to pickup the _Chrome Profile_ directory in a bit different way. See [Using Chrome settings in Selenium Webdriver Python 3](https://stackoverflow.com/questions/52394408/using-chrome-settings-in-selenium-webdriver-python-3) and [How to open a Chrome Profile through Python](https://stackoverflow.com/questions/49270109/how-to-open-a-chrome-profile-through-python) – undetected Selenium Sep 27 '18 at 06:06
  • @Newcontributor Sorry, but I don't quite understand. The code can run without issues if I just run one programme. – Winnie-c Sep 29 '18 at 12:39

1 Answers1

0

That is because we use the same profile at the same time. Take the following code for example:

Don't work:

h1="https://www.google.com"
h2="https://www.163.com"
d1= webdriver.Chrome(chrome_options=chrome_options)
d1.get(h1)

d2= webdriver.Chrome(chrome_options=chrome_options)
d2.get(h2)

Work:

h1="https://www.google.com"
h2="https://www.163.com"
d1= webdriver.Chrome(chrome_options=chrome_options)
d1.get(h1)

d2= webdriver.Chrome()
d2.get(h2)

Reason and solution can be seen in this.

Winnie-c
  • 179
  • 2
  • 13