我有幾個使用selenium/python自動執行的測試。 測試通過teamcity運行,位於安裝了Ubuntu 14.04的xfvb驅動器中。 所有28次的測試中,他們跑的時候,我看到運行瀏覽器(使用命令ps auvvx | grep的鍍鉻| grep的-v grep的)過程:Chrome瀏覽器隨機掛在從chromedriver開始
teamcity 31660 2.5 0.0 139000 8368 ? Sl 13:10 0:00 /opt/vendors/chromedriver/webdriver --port=50695 --log-path=chromedriverEnBundlesTests.log
teamcity 31680 27.3 0.2 625396 70948 ? Rl 13:10 0:00 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-gpu --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --lang=en --load-component-extension=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.EnML8k/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12388 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.65DCDh --v=1 --verbose --–-single-process data:,
teamcity 31693 1.0 0.0 335680 26132 ? S 13:10 0:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --v=1 --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.65DCDh
teamcity 31696 0.0 0.0 26192 2068 ? S 13:10 0:00 /opt/google/chrome/nacl_helper
teamcity 31699 0.0 0.0 335680 8448 ? S 13:10 0:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --v=1 --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.65DCDh
teamcity 31749 2.5 0.0 706404 31408 ? Sl 13:10 0:00 /opt/google/chrome/chrome --type=renderer --enable-logging --log-level=0 --test-type=webdriver --v=1 --primordial-pipe-token=1DE74651242181EC5B45C60E6057984B --lang=en-US --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.65DCDh --extension-process --disable-client-side-phishing-detection --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-pinch --num-raster-threads=4 --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --service-request-channel-token=1DE74651242181EC5B45C60E6057984B --renderer-client-id=2 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
teamcity 31772 14.5 0.1 734440 46176 ? Sl 13:10 0:00 /opt/google/chrome/chrome --type=renderer --enable-logging --log-level=0 --test-type=webdriver --v=1 --primordial-pipe-token=29BAB961D66EB1226D9E5A0151BC00FD --lang=en-US --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.65DCDh --disable-client-side-phishing-detection --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-pinch --num-raster-threads=4 --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --service-request-channel-token=29BAB961D66EB1226D9E5A0151BC00FD --renderer-client-id=4 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
但有時(它發生在一個隨機試驗)鉻無法啓動。沒有啓動 - 意味着chrome進程已經啓動,但chrome窗口沒有出現在屏幕上(我正在通過VNCviewer觀看xvfb)。然而,雖然鉻啓動進程,但他們看起來相當奇怪:
teamcity 30480 0.0 0.0 135880 7956 ? Sl 09:24 0:00 /opt/vendors/chromedriver/webdriver --port=34227 --log-path=chromedriverBundlesTests.log
teamcity 30485 0.0 0.1 558912 53480 ? Sl 09:24 0:00 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-gpu --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --lang=en --load-component-extension=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.xt55yX/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12290 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-agent=CustomUserAgent --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.pFyqzd --v=1 --verbose data:,
teamcity 30496 0.0 0.0 335680 26128 ? S 09:24 0:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --v=1 --user-agent=CustomUserAgent --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.pFyqzd
teamcity 30500 0.0 0.0 26192 2064 ? S 09:24 0:00 /opt/google/chrome/nacl_helper
teamcity 30503 0.0 0.0 335680 8432 ? S 09:24 0:00 /opt/google/chrome/chrome --type=zygote --enable-logging --log-level=0 --v=1 --user-agent=CustomUserAgent --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.pFyqzd
teamcity 30535 0.0 0.0 343876 10328 ? Sl 09:24 0:00 /opt/google/chrome/chrome --type=renderer --enable-logging --log-level=0 --test-type=webdriver --v=1 --primordial-pipe-token=059B5A32F7C1B61E6E6C194E4D3A0DC8 --lang=en-US --user-agent=CustomUserAgent --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.pFyqzd --disable-client-side-phishing-detection --enable-offline-auto-reload --enable-offline-auto-reload-visible-only --enable-pinch --num-raster-threads=4 --enable-main-frame-before-activation --content-image-texture-target=0,0,3553;0,1,3553;0,2,3553;0,3,3553;0,4,3553;0,5,3553;0,6,3553;0,7,3553;0,8,3553;0,9,3553;0,10,3553;0,11,3553;0,12,3553;0,13,3553;0,14,3553;0,15,3553;1,0,3553;1,1,3553;1,2,3553;1,3,3553;1,4,3553;1,5,3553;1,6,3553;1,7,3553;1,8,3553;1,9,3553;1,10,3553;1,11,3553;1,12,3553;1,13,3553;1,14,3553;1,15,3553;2,0,3553;2,1,3553;2,2,3553;2,3,3553;2,4,3553;2,5,3553;2,6,3553;2,7,3553;2,8,3553;2,9,3553;2,10,3553;2,11,3553;2,12,3553;2,13,3553;2,14,3553;2,15,3553;3,0,3553;3,1,3553;3,2,3553;3,3,3553;3,4,3553;3,5,3553;3,6,3553;3,7,3553;3,8,3553;3,9,3553;3,10,3553;3,11,3553;3,12,3553;3,13,3553;3,14,3553;3,15,3553 --disable-accelerated-video-decode --disable-webrtc-hw-encoding --disable-gpu-compositing --service-request-channel-token=059B5A32F7C1B61E6E6C194E4D3A0DC8 --renderer-client-id=3 --v8-natives-passed-by-fd --v8-snapshot-passed-by-fd
teamcity 30537 0.2 0.0 558668 14976 ? S 09:24 0:04 /opt/google/chrome/chrome --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-extensions --disable-gpu --disable-hang-monitor --disable-infobars --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web-resources --enable-logging --ignore-certificate-errors --lang=en --load-component-extension=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.xt55yX/internal --log-level=0 --metrics-recording-only --no-first-run --password-store=basic --remote-debugging-port=12290 --safebrowsing-disable-auto-update --test-type=webdriver --use-mock-keychain --user-agent=CustomUserAgent --user-data-dir=/var/tainted/build-agent/temp/buildTmp/.org.chromium.Chromium.pFyqzd --v=1 --verbose data:,
在這種狀態下,鉻可以保持幾個小時或幾天。下面 是測試的一個例子,我是如何從chromedriver運行Chrome瀏覽器:
def setUp(self):
os.environ["CHROME_LOG_FILE"] = 'DeTeasersTests.log'
chrome_options = Options()
chrome_options.add_argument('--verbose')
chrome_options.add_argument('--lang=en')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--enable-logging')
chrome_options.add_argument('--v=1')
chrome_options.add_argument('--ignore-certificate-errors')
chrome_options.add_argument('--disable-extensions')
if platform.system() == 'Linux':
service_log_path = "chromedriverDeTeasersTests.log"
self.driver = webdriver.Chrome('/opt/vendors/chromedriver/webdriver', chrome_options=chrome_options,
service_log_path=service_log_path)
elif platform.system() == 'Windows':
self.driver = webdriver.Chrome('chromedriver.exe', chrome_options=chrome_options,
service_log_path='chromedriver.log')
self.base_url = BASE_DE_URL
self.driver.get(self.base_url)
測試的尾巴:
def tearDown(self):
self.driver.close()
time.sleep(5)
self.driver.quit()
請幫忙找出錯誤是什麼?目前測試運行在2/3的情況下掛起。在Windows上,一切都完美無瑕。
p.s.如果我用英文寫錯了,我很抱歉。 我的母語 - 俄語,我在俄語互聯網上尋找解決方案,但什麼也沒找到。 p.p.s.我已經嘗試了很多方法來解決這個問題: 使用chrome參數(--no-sandbox,--single-process,--process-per-site,--disable-gpu等); 編寫並分析chrome和chromedriver的日誌 - 但日誌沒有例外或錯誤。