久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

我的 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:獲取當前星期幾的值)
主站蜘蛛池模板: 成人精品视频在线观看 | 中文亚洲字幕 | 国产精品久久久久久亚洲调教 | 欧美xxxx日本 | 亚洲丝袜天堂 | 国产丝袜一区二区三区免费视频 | 亚洲成av人片在线观看 | 亚洲精品一区二区在线观看 | 国产一级视频在线观看 | 日韩在线播放第一页 | 国产1页| 久久久久亚洲 | 求毛片| 91精品综合久久久久久五月天 | 99热精品国产 | 久久a久久 | 精品欧美一区二区三区久久久 | 99精品欧美| 日韩精品视频在线观看一区二区三区 | 在线日韩精品视频 | 一区二区精品在线 | 欧美一区二区在线 | 在线免费观看视频黄 | 国产91亚洲精品 | 成人区一区二区三区 | 国产成人一区二区 | 欧美日韩中文字幕在线 | 欧美日韩1区2区3区 欧美久久一区 | 国产在线视频一区 | 国产一区二区精品在线观看 | 亚洲精品日韩在线观看 | 毛片一级网站 | 精久久久 | 精品国产女人 | 欧洲成人 | 免费同性女女aaa免费网站 | 亚洲国产精品视频一区 | h视频在线看 | 99福利网| 亚洲国产成人在线视频 | 成人影音|