|
@@ -9,6 +9,7 @@ import com.example.demo.domain.WebConfig;
|
|
|
import com.example.demo.mapper.QrtzTaskMapper;
|
|
|
import com.example.demo.model.dto.QuartzTaskDTO;
|
|
|
import com.example.demo.util.FileUtils;
|
|
|
+import com.gargoylesoftware.htmlunit.javascript.background.JavaScriptExecutor;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.openqa.selenium.Alert;
|
|
|
import org.openqa.selenium.By;
|
|
@@ -287,43 +288,50 @@ public class UploadFromWebService {
|
|
|
|
|
|
//1.获得驱动
|
|
|
System.setProperty("webdriver.chrome.driver", "D:\\driver\\chromedriver.exe");
|
|
|
- //页面窗口最大化 仁杰 ↓
|
|
|
- //ChromeOptions chromeOptions = new ChromeOptions();
|
|
|
- //chromeOptions.addArguments("--start-maximized");
|
|
|
//2.创建驱动
|
|
|
- //ChromeDriver chromeDriver = new ChromeDriver(chromeOptions);
|
|
|
- ChromeDriver chromeDriver = new ChromeDriver();
|
|
|
- //3.页面窗口最大化
|
|
|
- chromeDriver.manage().window().maximize();
|
|
|
- //4.创建动作
|
|
|
- //Actions action = new Actions(chromeDriver);
|
|
|
+ ChromeDriver driver = new ChromeDriver();
|
|
|
+ //3.创建动作
|
|
|
+ Actions action = new Actions(driver);
|
|
|
+ //4.页面窗口最大化
|
|
|
+ driver.manage().window().maximize();
|
|
|
//5.设置等待时间
|
|
|
- WebDriverWait wait = new WebDriverWait(chromeDriver, 50);
|
|
|
+ WebDriverWait wait = new WebDriverWait(driver, 50);
|
|
|
|
|
|
//打开合享首页
|
|
|
- chromeDriver.get(webAddress);
|
|
|
+ driver.get(webAddress);
|
|
|
//等待直到出现id为"u"的元素,找到id为"u"和"p"的元素,并输入值(即输入账号密码)
|
|
|
wait.until(ExpectedConditions.presenceOfElementLocated(By.id("u")));
|
|
|
- WebElement username = chromeDriver.findElement(By.id("u"));
|
|
|
- WebElement password = chromeDriver.findElement(By.id("p"));
|
|
|
- username.sendKeys(webAccount);
|
|
|
- password.sendKeys(webPassword);
|
|
|
- //找到id为"clauseCheckBox"的元素,并点击(即点击同意服务条款)
|
|
|
- WebElement accept = chromeDriver.findElement(By.id("clauseCheckBox"));
|
|
|
+ driver.findElement(By.id("u")).sendKeys(webAccount);
|
|
|
+ driver.findElement(By.id("p")).sendKeys(webPassword);
|
|
|
+ //找到id为"clauseCheckBox"的元素,并(判断若当前元素没有被点击选择)点击(即点击同意服务条款)
|
|
|
+ WebElement accept = driver.findElement(By.id("clauseCheckBox"));
|
|
|
if (!accept.isSelected()) {
|
|
|
accept.click();
|
|
|
}
|
|
|
//找到id为"loginBtn"的元素,并点击(即点击登录按钮)
|
|
|
- WebElement loginButton = chromeDriver.findElement(By.id("loginBtn"));
|
|
|
- loginButton.click();
|
|
|
- //线程睡眠1秒等待alert弹窗提示账号正被登录,若此时有弹窗则点击确定按钮(即确认挤号)
|
|
|
+ driver.findElement(By.id("loginBtn")).click();
|
|
|
+ //线程睡眠1秒等待alert弹窗提示 "账号已被他人登录,是否继续登录?",若此时有该弹窗则点击确定按钮(即确认要挤号)
|
|
|
Thread.sleep(1000);
|
|
|
- Alert alert = chromeDriver.switchTo().alert();
|
|
|
+ Alert alert = driver.switchTo().alert();
|
|
|
if (alert != null) {
|
|
|
alert.accept();
|
|
|
}
|
|
|
|
|
|
+ //等待直到出现a标签为"检 索"的元素,找到该元素并将鼠标悬停其上(自动展开二级子菜单),找到a标签为"高级检索"的元素并点击
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.cssSelector("#container > div:nth-child(1) > div.top > div.top_con > div.menu > ul > li:nth-child(2) > a")));
|
|
|
+ action.moveToElement(driver.findElement(By.linkText("检 索"))).perform();
|
|
|
+ driver.findElement(By.linkText("高级检索")).click();
|
|
|
+
|
|
|
+ //等待直到出现id为"textarea"的元素,找到该元素并输入内容conditions,找到检索按钮的css路径并点击(即检索框中输入内容检索)
|
|
|
+ wait.until(ExpectedConditions.presenceOfElementLocated(By.id("textarea")));
|
|
|
+ driver.findElement(By.id("textarea")).sendKeys(conditions);
|
|
|
+ driver.findElement(By.cssSelector("#instructSearchDiv > div.button.citation_btn > input.retrieval")).click();
|
|
|
+
|
|
|
+ //
|
|
|
+
|
|
|
+
|
|
|
return null;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public List<PatentCell> getPatentya(String patentVO) throws IOException, InterruptedException {
|