美文网首页
2018-12-13java搜索框

2018-12-13java搜索框

作者: 洋洋爱可乐 | 来源:发表于2018-12-13 19:49 被阅读0次

    java (js代码)


    var xpath = "//input[@type='date']";var element = document.evaluate(xpath,document,null,XPathResult.ANY_TYPE,null).iterateNext();element.value="2018-12-13";改时间2018-12-13

    String js = "var xpath = "//input[@type='date']";var element = document.evaluate(xpath,document,null,XPathResult.ANY_TYPE,null).iterateNext();element.value="2018-12-13";";

    JavascriptExecutor jsDriver = (JavascriptExecutor)driver;

    jsDriver.executeScript(js);

    [图片上传失败...(image-f5c6ee-1544698008685)]

    修改时间 java代码(date-2018-12-20);

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">(文本,文件,数字,密码文本框代码)(淘宝搜索框-搜手机)</pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">public class TestUI extends BaseUI {
    @Test
    public void testTextInput(){
    driver.get("https://www.taobao.com/");
    WebElement text = driver.findElement(By.xpath("//input[@id='q']"));
    text.clear();
    text.sendKeys("手机");
    sleep(2);
    </pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">(淘宝按钮,找到搜索按钮代码)
    @Test
    public void testbutton() {
    testTextInput();
    WebElement button = driver .findElement(By.xpath("//button[contains(text(),'搜索')]"));
    button.click();
    sleep(2);
    }
    </pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">(淘宝文本框,搜索箱包)</pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">public void TestTextInput() {
    driver.get("https://www.taobao.com/");
    WebElement text = driver.findElement(By.xpath("//input[@id='q']"));
    text.clear();
    text.sendKeys("箱包");
    sleep(2);</pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">(淘宝超链接搜鲜花)</pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">[图片上传失败...(image-54a1ea-1544698008684)]

    (下拉框多选框测试-查找橘子和香蕉)

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">@Test public void testSelect(){
    driver.get("file://C:\Users\Administrator\Documents\WeChat Files\SL18551185539\Files\demo.html");
    WebElement select = driver.findElement(By.xpath("//select"));
    Select selects = new Select(select);
    selects.selectByVisibleText("香蕉");
    sleep(3);
    selects,selectBy index(0);
    sleep(2);
    selects,select Byvalue("橘子")
    sleep(3);
    </pre>

    (页面元素改日期)

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">public void testDate() {
    driver.get(
    "file://C:\Users\Administrator\Documents\WeChat Files\SL18551185539\Files\demo.html");
    WebElement date = driver.findElement(By.xpath("//input[@type='date']"));
    //date.clear();
    date.sendKeys("2018-12-13");
    String js = "var xpath = "//input[@type='date']";
    JavascriptExecutor jsDriver = (JavascriptExecutor) driver
    jsDriver.executeScript(js);
    sleep(2);</pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">[图片上传失败...(image-a8c220-1544698008682)]

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;"> (淘宝,京东,百度同时跳转搜索) </pre>

    <pre style="white-space: pre-wrap; overflow-wrap: break-word; font-family: 宋体; font-size: 12pt;">@Test
    public void testNavigate(){
    driver.get("https://www.baidu.com/");
    sleep(1);
    driver.get("https://www.jd.com/");
    sleep(1);
    driver.navigate().back();
    sleep(1);
    driver.navigate().forward();
    sleep(1);
    driver.navigate().refresh();
    sleep(1);
    driver.get("https://www.taobao.com/");
    sleep(1);
    }</pre>

    </pre>

    </pre>

    相关文章

      网友评论

          本文标题:2018-12-13java搜索框

          本文链接:https://www.haomeiwen.com/subject/ndgbhqtx.html