使用RestTemplate进行Selenium常规自动化测试操作

package com.luv2code.springbootecommerce;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.util.EntityUtils;
import org.apache.tomcat.jni.Time;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.*;
import org.springframework.stereotype.Component;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.web.client.RestTemplate;

import java.util.Iterator;
import java.util.Map;

/**
 * @Author:sun2y
 * @Description:<p></p>
 * @Date:2020/9/8 16:35
 */
@RunWith(SpringRunner.class)
@SpringBootTest
@Component
@Slf4j
public class fastJsonTest {

    static String hubUrl="http://127.0.0.1:4444/wd/hub";
    static String sessionApi="/session";
    static String deleteSessionApi="/session/:sessionId";
    static String getUrlApi="/session/:sessionId/url";
    static String findElementApi="/session/:sessionId/element";
    static String clickElementApi="/session/:sessionId/element/:id/click";
    static String sendKeysApi="/session/sessionId/element/:id/value";
    static String sessionId;

    @Autowired
    RestTemplate restTemplate;


    @Test
    public  void jsonTest() throws Exception {


        //启动浏览器获取session
         sessionId = getSessionId("chrome");

         try{
             //访问站点
             navigateTo("https://www.wind.com.cn");

             //通过CSS定位元素
//             String elementId=findElementByCss("#form1 > div.content > div.headTab > div > div > ul > li:nth-child(3) > a");

//             //通过Xpath定位元素
             String elementId = findElementByXpath("//*[@id='form1']/div[3]/div[2]/div/div/ul/li[3]/a");
             //点击元素
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值