2014-12-28 94 views
2

試圖使用appium打開android瀏覽器。我使用genymotion爲Android設備模擬器,並寫了下面的代碼..無法使用模擬器上的Appium或Real設備打開Android Browser

DesiredCapabilities capabilities = new DesiredCapabilities();   

capabilities.setCapability("platformName", "Android"); 
capabilities.setCapability("deviceName","Android Emulator"); 
capabilities.setCapability("browserName", "Browser"); 
capabilities.setCapability("platformVersion", "4.4"); 
capabilities.setCapability("Android", true); 
Driver_ST = new RemoteWebDriver(new URL("http://URL:4723/wd/hub"), capabilities); 

代碼執行後,如果我看到appium以下錯誤出現:

>info: [debug] [BOOTSTRAP] [debug] Returning result: {"value":"\/data","status":0} 
> info: [debug] dataDir set to: /data 
> info: [debug] Creating Chrome session 
> info: [debug] Set chromedriver binary as: D:\android\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe 
> info: [debug] Ensuring Chromedriver exists 
> info: [debug] Killing any old chromedrivers, running: FOR /F "usebackq tokens=5" %a in (netstat -nao ^| findstr /R /C:"9515 "`) do (FOR /F "usebackq" %b in (`TASKLIST /FI "PID eq %a" ^| findstr /I chromedriver.exe`) do (IF NOT %b=="" TASKKILL /F /PID %b)) 
> info: [debug] No old chromedrivers seemed to exist 
> info: [debug] Spawning chromedriver with: D:\android\Appium\node_modules\appium\build\chromedriver\windows\chromedriver.exe 
> info: [debug] [CHROMEDRIVER] Starting ChromeDriver (v2.10.267521) on port 9515 
> Only local connections are allowed. 
> info: [debug] Making http request with opts: 
{"sessionId":null,"desiredCapabilities":{"chromeOptions":{"androidPackage":"com.android.browser","androidActivity":"com.android.browser.BrowserActivity","androidDeviceSerial"}}}} 
> error: Chromedriver create session did not work. Status was 200 and body was {"sessionId":"b6aa64e8f25541d3513243792337a1e7","status":13,"value":{"message":"unknown error: Chrome version must be >= 33.0.1750.0\n (Driver info: chromedriver=2.10.267521,platform=Windows NT 6.3 x86_64)"}} 
> info: [debug] Cleaning up appium session 
> error: Failed to start an Appium session, err was: Error: Did not get session redirect from Chromedriver 
> info: [debug] Error: Did not get session redirect from Chromedriver 
>  at null.<anonymous> (D:\android\Appium\node_modules\appium\lib\devices\android\chromedriver.js:222:12) 
>  at Request._callback (D:\android\Appium\node_modules\appium\lib\devices\common.js:121:5) 
>  at Request.self.callback (D:\android\Appium\node_modules\appium\node_modules\request\request.js:121:22) 
>  at Request.EventEmitter.emit (events.js:98:17) 
>  at Request.<anonymous> (D:\android\Appium\node_modules\appium\node_modules\request\request.js:985:14) 
>  at Request.EventEmitter.emit (events.js:117:20) 
>  at IncomingMessage.<anonymous> (D:\android\Appium\node_modules\appium\node_modules\request\request.js:936:12) 
>  at IncomingMessage.EventEmitter.emit (events.js:117:20) 
>  at _stream_readable.js:920:16 
>  at process._tickDomainCallback (node.js:459:13) 
> info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Did not get session redirect from Chromedriver)","origValue":"Did not get session redirect from Chromedriver"},"sessionId":null} 
> info: <-- POST /wd/hub/session 500 28735.979 ms - 214 

那麼,爲什麼這是給我的錯誤chromedriver的會話無法創建,但我試圖打開Android瀏覽器。

請幫忙。我是否缺少任何功能或需要安裝的驅動程序?

+0

您使用的是什麼版本'chromedriver'? – Saifur

+0

我正在使用更新chrome驅動程序,並能夠使用appium在真實設備上打開chrome瀏覽器。但不是真正的設備或模擬器上的Android瀏覽器。 – avni

+0

avni,你有沒有得到任何解決你的問題。我也在同一艘船上航行。目前尚未得到任何解決方案。如果您有任何解決方案,請幫助我。 – Uday

回答

0

使用捆綁的Chromedriver服務器作爲代理實現自動化。在4.2和4.3版本中,自動化僅適用於官方Chrome瀏覽器或Chromium。使用4.4+,自動化也可以在內置的「瀏覽器」應用程序上運行。 Chrome/Chromium/Browser必須已經安裝在被測設備上。

+0

不明白你可以詳細說明..我使用的模擬器是有OS 4.4。 – avni

+0

嘗試從Play商店安裝Chrome,並試一試。 –

1

我使用此代碼sample.That works.Please嘗試打開(自動化名稱:Selendroid)在真實設備

@Before 
public void setUp() throws Exception { 
    PropertyConfigurator.configure("log4j.properties"); 
    // set up appium 
    File app = new File(SignUpElement.apkFilePath); 

    DesiredCapabilities capabilities = new DesiredCapabilities(); 
    capabilities.setCapability(CapabilityType.BROWSER_NAME, ""); 

    capabilities.setCapability(GeneralElement.device, GeneralElement.deviceType); 
    capabilities.setCapability(GeneralElement.emulator, GeneralElement.emulatorType); 
    capabilities.setCapability(GeneralElement.platformVer, GeneralElement.platformVerType); 
    capabilities.setCapability(GeneralElement.platformName, GeneralElement.platformNameType); 
    capabilities.setCapability("appPackage", ""); 
    capabilities.setCapability("appActivity", ""); 
    capabilities.setCapability("app", app.getAbsolutePath()); 

    try { 
     WebElementFactory.driver = new AppiumDriver(new URL("http://127.0.0.1:4723/wd/hub"), capabilities); 
    } catch (MalformedURLException e) { 
     e.printStackTrace(); 
    } 
+2

我想你打開應用程序通過此代碼但我想打開Android瀏覽器不應用也使用appium而不是selendroid。 – avni

0

股票瀏覽器is not working與Appium 1.3.6
你要等到它會被修復。

不過,在模擬器上啓動它應該沒有問題。 你可以試試嗎?

Chrome適用於真正的設備。

It's not possible現在安裝在Android模擬器上。

有一句關於Android模擬器的警告。在 的那一刻,有沒有辦法在Android模擬器安裝Chrome

0

我將功能設置appBrowser,它爲我的作品 -

capabilities.setCapability("app", "Browser"); 

即使我給錯誤的設備名稱或版本,appium仍然發現附加的模擬器,並啓動瀏覽器。我的整套功能看起來像 -

capabilities.setCapability("BROWSER_NAME", "Android"); 
    capabilities.setCapability("app", "Browser"); 
    capabilities.setCapability("VERSION", "XXX"); 
    capabilities.setCapability("deviceName", "XXX"); 
    capabilities.setCapability("platformName", "Android"); 
    driver = new AndroidDriver(new URL("http://localhost:4723/wd/hub"), capabilities); 
    driver.get("http://www.google.com/"); 
相關問題