123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- package org.jeecg;
- import cn.com.ctop.common.module.utils.HttpUtils2;
- import cn.com.ctop.crawler.modules.appium.service.IAppiumJobService;
- import cn.com.ctop.crawler.modules.appium.service.IAppiumTaskService;
- import cn.com.ctop.kuaishou.modules.batch.service.IAccountWarningService;
- import cn.com.ctop.kuaishou.modules.batch.service.IKuaishouInterfaceService;
- import lombok.extern.slf4j.Slf4j;
- import org.apache.http.impl.client.BasicCookieStore;
- import org.jeecg.modules.ctop.service.IBidWarningService;
- import org.jeecg.modules.ctop.service.ICreateInternalService;
- import org.jeecg.modules.mq.Sender;
- import org.junit.Test;
- import org.junit.runner.RunWith;
- import org.openqa.selenium.By;
- import org.openqa.selenium.JavascriptExecutor;
- import org.openqa.selenium.WebDriver;
- import org.openqa.selenium.WebElement;
- import org.openqa.selenium.chrome.ChromeDriver;
- import org.openqa.selenium.chrome.ChromeOptions;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.boot.test.context.SpringBootTest;
- import org.springframework.test.context.junit4.SpringRunner;
- import java.util.List;
- @RunWith(SpringRunner.class)
- @SpringBootTest
- @Slf4j
- public class SampleTest {
- @Value("${jeecg.path.chrome-driver}")
- private String chromeDriver;
- @Autowired
- private IAppiumJobService jobService;
- @Autowired
- private ICreateInternalService createInternalService;
- @Autowired
- private IAppiumTaskService appiumTaskService;
- @Test
- public void testKs() throws InterruptedException {
- String url = "https://ad.e.kuaishou.com/#/welcome?redirectUrl=https%3A%2F%2Fad.e.kuaishou.com%2F%23%2Findex";
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
- ChromeOptions chromeOptions = new ChromeOptions();
- // chromeOptions.addArguments("--headless");
- chromeOptions.addArguments("--incognito");
- chromeOptions.addArguments("--disable-gpu");
- // chromeOptions.addArguments("--no-sandbox");
- chromeOptions.addArguments("--window-size=1920,1080");
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
- chromeOptions.setAcceptInsecureCerts(true);
- WebDriver webDriver = new ChromeDriver(chromeOptions);
- try {
- Thread.sleep(3000L);
- HttpUtils2.cookieStore = new BasicCookieStore();
- webDriver.manage().deleteAllCookies();
- //获取登录页面
- webDriver.get(url);
- Thread.sleep(3000L);
- WebElement accountElement = webDriver.findElement(By.xpath("//div[@class='phone ']/input[@type='text']"));
- accountElement.sendKeys("19845004383");
- Thread.sleep(3000L);
- WebElement passwordElement = webDriver.findElement(By.xpath("//div[@class='password ']/input[@type='password']"));
- passwordElement.sendKeys("a123456");
- WebElement loginElement = webDriver.findElement(By.xpath("//div[@class='foot']"));
- Thread.sleep(3000L);
- //点击登录
- loginElement.click();
- Thread.sleep(3000L);
- //获取推广按钮
- WebElement spreadElement = webDriver.findElement(By.linkText("推广"));
- spreadElement.click();
- Thread.sleep(3000L);
- //选择广告创意
- WebElement creativeElement = webDriver.findElement(By.xpath("//div[text()='广告创意']"));
- creativeElement.click();
- Thread.sleep(3000L);
- //输入创意名称,点击搜索
- WebElement searchElement = webDriver.findElement(By.xpath("//input[@type='text']"));
- searchElement.sendKeys("2-这个是你画的吗-设计-11.19");
- Thread.sleep(3000L);
- WebElement searchButton = webDriver.findElement(By.xpath("//button[@class='ant-btn ant-input-search-button ant-btn-primary']"));
- searchButton.click();
- Thread.sleep(3000L);
- WebElement tiyanElement = webDriver.findElement(By.linkText("体验"));
- tiyanElement.click();
- Thread.sleep(2000L);
- WebElement inputKsIdElement = webDriver.findElement(By.xpath("//textarea[@placeholder='请输入快手账号…']"));
- inputKsIdElement.sendKeys("123456765");
- Thread.sleep(2000L);
- WebElement chufaElement = webDriver.findElement(By.xpath("//button[@class='creative-experience-btn-enable']"));
- chufaElement.click();
- } catch (Exception e) {
- e.printStackTrace();
- webDriver.manage().deleteAllCookies();
- webDriver.close();
- }
- }
- @Test
- public void test() {
- jobService.refreshWebPhone();
- }
- @Test
- public void testMq() {
- Sender sender = new Sender();
- sender.send();
- }
- @Test
- public void loadKuaishouDataSingle() throws Exception {
- String url = "https://a201903112120030590198943.szwego.com/static/index.html#/shop_detail/A201903112120030590198943";
- System.getProperties().setProperty("webdriver.chrome.driver", chromeDriver);
- ChromeOptions chromeOptions = new ChromeOptions();
- // chromeOptions.addArguments("--headless");
- chromeOptions.addArguments("--incognito");
- chromeOptions.addArguments("--disable-gpu");
- // chromeOptions.addArguments("--no-sandbox");
- chromeOptions.addArguments("--window-size=1920,1080");
- chromeOptions.addArguments("--user-agent=" + HttpUtils2.USER_AGENT);
- chromeOptions.setAcceptInsecureCerts(true);
- WebDriver webDriver = new ChromeDriver(chromeOptions);
- webDriver.get(url);
- Thread.sleep(3000L);
- ((JavascriptExecutor) webDriver).executeScript("window.scrollTo(0,document.body.scrollHeight)");
- Thread.sleep(3000L);
- List<WebElement> elementList = webDriver.findElements(By.xpath("//div[@class='word-break ellipsis-two f14 g3']"));
- for (WebElement element : elementList) {
- System.out.println(element.getText());
- }
- }
- @Autowired
- private IKuaishouInterfaceService kuaishouInterfaceService;
- @Test
- public void testMail() throws Exception {
- // String accessToken, Long advertiserId, Date startDate, Date endDate, Integer page
- kuaishouInterfaceService.getGroupList("adf659b9b43e8952f9a3f0c5269505ca", 35675L, null, null, 1);
- }
- @Autowired
- private IBidWarningService bidWarningService;
- @Autowired
- private IAccountWarningService accountWarningService;
- @Test
- public void testMa() throws Exception {
- // accountWarningService.accountWarning(23212L);
- }
- }
|