日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

[Selenium]Grid模式下運行時打印出當(dāng)前Case在哪

系統(tǒng) 2049 0

當(dāng)Case在本地運行成功,在Grid模式下運行失敗時,我們需要在Grid模式下進(jìn)行調(diào)試,同時登錄遠(yuǎn)程的node去查看運行的情況。

Hub是隨機將case分配到某臺node上運行的,怎樣知道當(dāng)前的case是運行在哪臺node上呢?

可以通過這段代碼獲取node的信息:

      public void getComputerNameOfNode(WebDriver driver){

		String hub = "SZAUTOTEST1";

		int port = 4444;

		HttpClientBuilder httpClientBuilder = HttpClientBuilder.create();

		CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); 

		

		String sessionUrl = "http://" + hub + ":" + port+ "/grid/api/testsession?session="+((RemoteWebDriver) driver).getSessionId();

		HttpPost httpPost = new HttpPost(sessionUrl); 

		System.out.println("Http post request is : "+httpPost.getRequestLine());

		try{

			//Execute HTTP request

            HttpResponse httpResponse = closeableHttpClient.execute(httpPost);  

            //Get HTTP response

            HttpEntity entity = httpResponse.getEntity();  

            //Response status

            System.out.println("HTTP status:" + httpResponse.getStatusLine());  

            //Check if response is null

            if (entity != null) {  

            	System.out.println("Content encoding:" + entity.getContentEncoding()); 

            	String jsonString = EntityUtils.toString(entity);

            	System.out.println("Response content:" + jsonString);

            	JSONObject jsonObject = JSONObject.fromObject(jsonString);

            	String proxyID=jsonObject.getString("proxyId");

            	String node = (proxyID.split("http://")[1].split(":")[0]);

            	System.out.println("The case is running on this node :" + node);

            }

		}

		catch(IOException e){

			e.printStackTrace();  

		}

		finally{

			try{

				closeableHttpClient.close();  

			}

			catch(IOException e){

				 e.printStackTrace();  

			}

		}

    }  


    

?

[Selenium]Grid模式下運行時打印出當(dāng)前Case在哪臺node機器上運行


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯(lián)系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發(fā)表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 安福县| 鄄城县| 永登县| 双辽市| 陆丰市| 盐城市| 济阳县| 祁东县| 乐安县| 罗源县| 泗阳县| 昌吉市| 禄丰县| 云林县| 湟源县| 溆浦县| 鹤岗市| 峨眉山市| 融水| 云阳县| 平遥县| 阿坝| 左权县| 萨嘎县| 扬州市| 岳西县| 钦州市| 溆浦县| 巴塘县| 娄烦县| 伊川县| 临沭县| 上林县| 开平市| 灵川县| 准格尔旗| 嘉善县| 囊谦县| 连州市| 河南省| 黔南|