赞
踩
- public class SellenumClickTest {
-
- public static void main(String[] args) {
- System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
- ChromeOptions chromeOptions = new ChromeOptions();
- chromeOptions.addArguments("--disable-extensions");//禁用插件
- chromeOptions.addArguments("--disable-infobars");//禁用消息条
- WebDriver webDriver = new ChromeDriver();
- webDriver.get("https://fanyi.youdao.com/index.html#/");
- WebElement input = ((ChromeDriver) webDriver).findElementById("js_fanyi_input");
- input.sendKeys("I am a good student.");
- //静态等待5s
- WebDriverWait webDriverWait = new WebDriverWait(webDriver, 5);
- WebElement transTarget = webDriverWait.until(currentDriver -> {
- return webDriver.findElement(By.id("js_fanyi_output_resultOutput"));
- });
- System.out.println(transTarget.getText());
- }
- }

- public class SellenumClickTest {
-
- public static void main(String[] args) {
- System.setProperty("webdriver.chrome.driver", "/usr/local/bin/chromedriver");
- ChromeOptions chromeOptions = new ChromeOptions();
- chromeOptions.addArguments("--disable-extensions");//禁用插件
- chromeOptions.addArguments("--disable-infobars");//禁用消息条
- WebDriver webDriver = new ChromeDriver();
- webDriver.get("https://fanyi.youdao.com/index.html#/");
- //输入英文
- WebElement input = ((ChromeDriver) webDriver).findElementById("js_fanyi_input");
- input.sendKeys("I am a good student.");
- //点击翻译
- WebDriverWait webDriverWait = new WebDriverWait(webDriver, 1);
- WebElement click = webDriverWait.until(currentDriver -> {
- return webDriver.findElement(By.linkText("翻译"));
- });
- Actions action = new Actions(webDriver);
- action.click(click).perform();
- //输出中文
- WebElement output = webDriver.findElement(By.id("js_fanyi_output_resultOutput"));
- System.out.println(output.getText());
- webDriver.quit();
- }
- }

Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。