pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

我的 selenium 框架可以使用傳入的消息嗎

Can my selenium framework consume an incoming message(我的 selenium 框架可以使用傳入的消息嗎)
本文介紹了我的 selenium 框架可以使用傳入的消息嗎的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我想知道我的 Selenium 框架如何使位于消息隊列中的消息出列.我已經構建了一個應用程序來將包含 k/v 對的 JSON 字符串發送到消息隊列.

我的架構如下和單獨的應用程序:

  1. 存在一個 JSP Web 應用程序,它接受導致 JSON 字符串的參數
  2. 存在消息發送者并獲取 JSON 字符串并將其發布到隊列
  3. 存在消息消費者并使用消息.它基本上只是坐在這里
  4. 存在 Selenium Java 框架,但我想處理消息,并且對于每條消息,它將解釋 k/v 對并啟動腳本.

我想使用已經在隊列中的消息,并在 selenium 框架中處理這些消息,我該如何實現呢?

我將不勝感激.我已經用代碼編輯了問題

<塊引用>

這是發送 JSON 消息的代碼片段

公共類 MessageSender {公共靜態 void main(String[] args) 拋出 IOException {SingleNumberLogin generateLogin = new SingleNumberLogin();//用于構建JSON對象的函數調用字符串 jsonQueue = generateLogin.buildJASONObject();ConnectionFactory conFactory = new ConnectionFactory();嘗試 {連接 connInterface = conFactory.newConnection();頻道 mqChannel = connInterface.createChannel();mqChannel.queueDeclare("MyQ??ueue",false,false,false,null);//只是將json分配給另一個字符串,然后發布消息字符串 myMessage = jsonQueue;mqChannel.basicPublish(",MyQueue",false ,false, null,myMessage.getBytes());}抓住 (異常 |超時異常 e){System.out.println(e.getStackTrace());}conFactory.setUsername("guest");conFactory.setPassword("guest");conFactory.setVirtualHost("/");conFactory.setHost(本地主機");conFactory.setPort(5672);}

}

<塊引用>

我已插入到自動化腳本的啟動函數中的消費者代碼的代碼片段,因此如果消息到達,則執行單個測試用例

 @BeforeTestpublic static void initializeTestBaseSetup() 拋出異常,IOException,TimeoutException {ConnectionFactory conFactory = new ConnectionFactory();連接 connInterface = conFactory.newConnection();頻道 mqChannel = connInterface.createChannel();mqChannel.queueDeclare("MyQ??ueue",false,false,false,null);mqChannel.basicConsume("MyQ??ueue", true, (consumerTag, message) -> {//轉換為字節數組String m = new String (message.getBody(), "UTF-8");System.out.println(收到消息"+ m);},消費者標簽->{});}

<塊引用>

輸出 JSON

收到的 JSON 消息 2020-08-28T20:39:30.845{

 "NUMBER": "0000011111",類型":BAU",用戶":我的用戶",電子郵件":riidonesh@gmail.com",}

當單獨測試時,它工作得非常好,我的意思是我發送消息并檢查消費者是否收到它,將消費者代碼添加到我的框架是我卡住的地方.

解決方案

我建議你不要考慮你有什么作為selenium 框架";- 將其視為java 框架".

Selenium 是一組庫,可讓您在 GUI 級別自動化 Web 瀏覽器.該框架是有助于創建和管理測試套件的編碼解決方案 - 它不必局限于 selenium,而且很有可能這只是它的組件之一.

嘗試直接回答您的問題:

  • SELENIUM 無法讀取消息
  • JAVA 可以閱讀消息

如果你的 rabbitmq 有一個 web 前端,那么你也許可以使用 selenium,但這不是一個非常有效或合乎邏輯的解決方案.

您可能想要考慮的以及我會做的事情是擴展您的框架以使用 rabbitmq 庫來處理您需要的消息.這些庫是為此任務而設計的.

你說:

<塊引用>

我想處理這些消息,并且對于每條消息它都會解釋 k/v 對并啟動腳本.

我理解這意味著消息是測試的 pre-req 數據.如果您想在測試前讀取消息的值,您可以:

  • 將 get/read 放在通用 @Before 方法中
  • 或者,如果它是每個測試用例的特定消息,請將其添加到測試的開頭.

你正在使用java,所以你可以做任何你想做的事情.

為了幫助您入門,rabbitmq 教程從這里開始.

這是從隊列中讀取消息的 hello world 示例:

公共類 Recv {私有最終靜態字符串 QUEUE_NAME = 你好";公共靜態 void main(String[] argv) 拋出異常 {ConnectionFactory 工廠 = new ConnectionFactory();factory.setHost("localhost");連接連接 = factory.newConnection();頻道 channel = connection.createChannel();channel.queueDeclare(QUEUE_NAME, false, false, false, null);System.out.println("[*] 等待消息.退出按 CTRL+C");}}

I would like to know how my Selenium framework can dequeue a message sitting in a message queue. I have built an application to send a JSON string containing k/v pairs to a message queue.

My architecture is as follows and separate apps:

  1. A JSP Web Application exists accepting parameters resulting in a JSON string
  2. A message sender exists and takes the JSON string and publishes it to a Queue
  3. A message consumer exists and consumes the Messages. Its basically just sitting here
  4. A Selenium Java Framework exists, but I would like to process the messages and for each message it will interpret the k/v pairs and kicks off the script.

I would like to use the messages already in the queue and process these messages within the selenium framework, how can I achieve this?

I will appreciate the help. I have edited the question with the code

This is the code snippet to send the JSON Message

public class MessageSender {
public static void main(String[] args) throws IOException {

    SingleNumberLogin generateLogin = new SingleNumberLogin();
    //function call to build the JSON object
    String jsonQueue = generateLogin.buildJASONObject();

    ConnectionFactory conFactory = new ConnectionFactory();
    try {
        Connection connInterface =  conFactory.newConnection();
        Channel mqChannel = connInterface.createChannel();
        mqChannel.queueDeclare("MyQueue",false,false,false,null);
        //Just assigning json to another string, then publish the message      
        String myMessage = jsonQueue;

        mqChannel.basicPublish("","MyQueue",false ,false, null,myMessage.getBytes());
    }catch (
            IOException | TimeoutException e)
    {
        System.out.println(e.getStackTrace());
    }
    conFactory.setUsername("guest");
    conFactory.setPassword("guest");
    conFactory.setVirtualHost("/");
    conFactory.setHost("localhost");
    conFactory.setPort(5672);
}

}

code snippet for consumer code that I have inserted into the startup function of the automation script, so if a message arrives a single test case is executed

    @BeforeTest
public static void initializeTestBaseSetup() throws Exception, IOException, TimeoutException {
    ConnectionFactory conFactory = new ConnectionFactory();
    Connection connInterface =  conFactory.newConnection();
    Channel mqChannel = connInterface.createChannel();
    mqChannel.queueDeclare("MyQueue",false,false,false,null);
    mqChannel.basicConsume("MyQueue", true, (consumerTag, message) -> {
        //convert to byte array
        String m = new String (message.getBody(), "UTF-8");
        System.out.println("Message received" + m);
    }, consumerTag -> {

    });
}

Output JSON

JSON Message received 2020-08-28T20:39:30.845{

  "NUMBER": "0000011111",
  "Type": "BAU",
  "User": "MyUser ",
  "Email": "riidonesh@gmail.com",
}

When tested in isolation, it works perfectly fine, what I mean is that I send the message and check that the consumer receives it, adding the consumer code to my framework is where i am stuck.

解決方案

I would suggest you don't think about what you have as a "selenium framework" - think of it as a "java framework".

Selenium is a set of libraries that allow you automate the web browser at a GUI level. The framework is the coded solution to facilitate creation and management of your test suite - it doesn't have to be limited to selenium and chances that's already just one of its components.

Trying to answer your question directly:

  • SELENIUM cannot read messages
  • JAVA can read messages

If your rabbitmq has a web front end then you may be able to use selenium for it, but this isn't a very efficient or a logical solution.

What you might want to consider, and what i would do, is extending your framework to use the rabbitmq libraries to process messages as you need. These libraries are designed for this task.

You say:

I would like to process the messages and for each message it will interpret the k/v pairs and kicks off the script.

I understand this to mean that the messages are the pre-req data for the tests. If you want to read the values of a message before the test you can either:

  • Place the get/read in a generic @Before method
  • or if it's a specific message per test case, add it into the start of the test.

You're working in java so you can do whatever you want really.

To get you started, the rabbitmq tutorial starts here.

This is there hello world example for reading messages from the queue:

public class Recv {

  private final static String QUEUE_NAME = "hello";

  public static void main(String[] argv) throws Exception {
    ConnectionFactory factory = new ConnectionFactory();
    factory.setHost("localhost");
    Connection connection = factory.newConnection();
    Channel channel = connection.createChannel();

    channel.queueDeclare(QUEUE_NAME, false, false, false, null);
    System.out.println(" [*] Waiting for messages. To exit press CTRL+C");

  }
}

這篇關于我的 selenium 框架可以使用傳入的消息嗎的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Parsing an ISO 8601 string local date-time as if in UTC(解析 ISO 8601 字符串本地日期時間,就像在 UTC 中一樣)
How to convert Gregorian string to Gregorian Calendar?(如何將公歷字符串轉換為公歷?)
Java: What/where are the maximum and minimum values of a GregorianCalendar?(Java:GregorianCalendar 的最大值和最小值是什么/在哪里?)
Calendar to Date conversion for dates before 15 Oct 1582. Gregorian to Julian calendar switch(1582 年 10 月 15 日之前日期的日歷到日期轉換.公歷到儒略歷切換)
java Calendar setFirstDayOfWeek not working(java日歷setFirstDayOfWeek不起作用)
Java: getting current Day of the Week value(Java:獲取當前星期幾的值)
主站蜘蛛池模板: 山楂片_雪花_迷你山楂片_山楂条饼厂家-青州市丰源食品厂 | 合肥网带炉_安徽箱式炉_钟罩炉-合肥品炙装备科技有限公司 | 辐射色度计-字符亮度测试-反射式膜厚仪-苏州瑞格谱光电科技有限公司 | 中国在职研究生招生信息网| 存包柜厂家_电子存包柜_超市存包柜_超市电子存包柜_自动存包柜-洛阳中星 | 地图标注-手机导航电子地图如何标注-房地产商场地图标记【DiTuBiaoZhu.net】 | 二手电脑回收_二手打印机回收_二手复印机回_硒鼓墨盒回收-广州益美二手电脑回收公司 | 深圳离婚律师咨询「在线免费」华荣深圳婚姻律师事务所专办离婚纠纷案件 | 防水套管厂家-柔性防水套管-不锈钢|刚性防水套管-天翔管道 | 滑板场地施工_极限运动场地设计_滑板公园建造_盐城天人极限运动场地建设有限公司 | 发电机组|柴油发电机组-批发,上柴,玉柴,潍柴,康明斯柴油发电机厂家直销 | 泰国试管婴儿_泰国第三代试管婴儿费用|成功率|医院—新生代海外医疗 | lcd条形屏-液晶长条屏-户外广告屏-条形智能显示屏-深圳市条形智能电子有限公司 | 江苏南京多语种翻译-专业翻译公司报价-正规商务翻译机构-南京华彦翻译服务有限公司 | 冷凝锅炉_燃气锅炉_工业燃气锅炉改造厂家-北京科诺锅炉 | PCB接线端子_栅板式端子_线路板连接器_端子排生产厂家-置恒电气 喷码机,激光喷码打码机,鸡蛋打码机,手持打码机,自动喷码机,一物一码防伪溯源-恒欣瑞达有限公司 假肢-假肢价格-假肢厂家-河南假肢-郑州市力康假肢矫形器有限公司 | 无机纤维喷涂棉-喷涂棉施工工程-山东华泉建筑工程有限公司▲ | 水性绝缘漆_凡立水_绝缘漆树脂_环保绝缘漆-深圳维特利环保材料有限公司 | MVR蒸发器厂家-多效蒸发器-工业废水蒸发器厂家-康景辉集团官网 | 广东高华家具-公寓床|学生宿舍双层铁床厂家【质保十年】 | 潜水搅拌机-双曲面搅拌机-潜水推进器|奥伯尔环保 | 网站建设-临朐爱采购-抖音运营-山东兆通网络科技 | 学考网学历中心| 电磁辐射仪-电磁辐射检测仪-pm2.5检测仪-多功能射线检测仪-上海何亦仪器仪表有限公司 | 水稻烘干机,小麦烘干机,大豆烘干机,玉米烘干机,粮食烘干机_巩义市锦华粮食烘干机械制造有限公司 水环真空泵厂家,2bv真空泵,2be真空泵-淄博真空设备厂 | 小型高低温循环试验箱-可程式高低温湿热交变试验箱-东莞市拓德环境测试设备有限公司 | 新车测评网_网罗汽车评测资讯_汽车评测门户报道 | 不锈钢闸阀_球阀_蝶阀_止回阀_调节阀_截止阀-可拉伐阀门(上海)有限公司 | 杭州公司变更法人-代理记账收费价格-公司注销代办_杭州福道财务管理咨询有限公司 | 知名电动蝶阀,电动球阀,气动蝶阀,气动球阀生产厂家|价格透明-【固菲阀门官网】 | 托利多电子平台秤-高精度接线盒-托利多高精度电子秤|百科 | 济南品牌包装设计公司_济南VI标志设计公司_山东锐尚文化传播 | 小区健身器材_户外健身器材_室外健身器材_公园健身路径-沧州浩然体育器材有限公司 | 在线浊度仪_悬浮物污泥浓度计_超声波泥位计_污泥界面仪_泥水界面仪-无锡蓝拓仪表科技有限公司 | 政府回应:200块在义乌小巷能买到爱情吗?——揭秘打工族省钱约会的生存智慧 | 根系分析仪,大米外观品质检测仪,考种仪,藻类鉴定计数仪,叶面积仪,菌落计数仪,抑菌圈测量仪,抗生素效价测定仪,植物表型仪,冠层分析仪-杭州万深检测仪器网 | 砂磨机_立式纳米砂磨机_实验室砂磨机-广州儒佳化工设备厂家 | [品牌官网]贵州遵义双宁口腔连锁_贵州遵义牙科医院哪家好_种植牙_牙齿矫正_原华美口腔 | led全彩屏-室内|学校|展厅|p3|户外|会议室|圆柱|p2.5LED显示屏-LED显示屏价格-LED互动地砖屏_蕙宇屏科技 | 减速机_上海宜嘉减速机| 高铝矾土熟料_细粉_骨料_消失模_铸造用铝矾土_铝酸钙粉—嵩峰厂家 |