美文网首页
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搜索框

    java (js代码) var xpath = "//input[@type='date']";var eleme...

  • 搜索框控制器问题总结

    最简易的搜索框控制器 设置搜索框uisearchBar的背景色 设置搜索框弹出的背景色 去掉搜索框的黑线 修改光标颜色

  • 子类控件-快捷代码

    按钮 搜索框 点击跳转 搜索框 点击搜索 KVO 保存图片 判断viewLoad是否加载 for 循环

  • 搜索框

    #import "RootViewController.h" //编辑搜索框需要遵守两个协议: //UISearc...

  • 搜索框

    来一张效果图看看,在这里不能传视频,(鼠标放置时,搜索框变长,背景颜色改变): 先来看一下HTML代码,很简单,就...

  • 搜索框

    https://my.oschina.net/u/2340880/blog/509756 (搜索框的详细属性方法)...

  • 搜索框

    使用type=search的元素 在元素内,使用appearance:none 使用伪元素,去掉不必要的样式 以上...

  • 搜索框

    最近自己在写一个APP,其中需要实现搜索框搜索功能,于是乎就想写篇博客介绍下UISearchController和...

  • 搜索框

  • 搜索框

    要实现一个搜索功能,筛选功能。用系统自带的UISearchController有一些问题,不够灵活, 所以使用自定...

网友评论

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

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