• 作业3

  • Docker 实战 at March 08, 2019

    练习4

    练习5

  • github地址:https://github.com/Nick0136/AppiumTest

    StockinfoPage

    package page;

    import driver.Driver;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.support.ui.ExpectedConditions;
    import sun.security.util.PropertyExpander;


    public class StockinfoPage extends BasePage {

    private By set= By.xpath("//*[@text='设自选']");
    private By addSet= By.xpath("//*[@text='加自选']");
    private By delete=text("删除自选");
    private By modify=text("修改分组");


    public StockinfoPage deleteSelect() {

    WebElement el = Driver.getWait().until(ExpectedConditions.presenceOfElementLocated(set));
    if (el.getText() == "设自选") {
    el.click();
    }else{
    System.out.println(el.getText());
    Driver.getWait().until(ExpectedConditions.presenceOfElementLocated(set)).click();
    }

    find(delete).click();
    return new StockinfoPage();
    }


    public String getSetText(){
    return Driver.getWait().until(ExpectedConditions.presenceOfElementLocated(addSet)).getText();
    }

    public String getToast(){
    WebElement element=Driver.getWait().until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//*[@class='android.widget.Toast']")));
    return element.getText();
    }

    }

    Zixuanpage

    package page;

    import driver.Driver;
    import org.openqa.selenium.By;
    import org.openqa.selenium.WebElement;

    import java.util.ArrayList;

    public class ZixuanPage extends BasePage {

    private By stock = By.xpath("//*[@resource-id='com.xueqiu.android:id/listview']/android.widget.FrameLayout[1]");
    private By stockName = By.id("portfolio_stockName");
    public SearchPage gotoSearch(){
    find(By.id("action_create_cube")).click();
    return new SearchPage();
    }

    public StockinfoPage gotoStockinfo(){
    find(stock).click();
    return new StockinfoPage();
    }

    public ArrayList<String> getStocks(){
    ArrayList<String> arrayList=new ArrayList<String>();
    for (WebElement e : Driver.getCurrentDriver().findElements(stockName)){
    arrayList.add(e.getText());
    System.out.println(arrayList);
    }
    return arrayList;

    }

    }

    ZixuanTest

    import org.junit.jupiter.api.BeforeAll;
    import org.junit.jupiter.api.Test;
    import org.springframework.core.annotation.Order;
    import page.MainPage;
    import page.ZixuanPage;

    import java.util.ArrayList;

    import static org.hamcrest.CoreMatchers.hasItems;
    import static org.hamcrest.MatcherAssert.*;
    import static org.hamcrest.Matchers.equalTo;


    public class ZixuanTest {

    static MainPage mainPage;
    static ZixuanPage zixuanPage;

    @BeforeAll
    static void beforeAll(){
    mainPage= MainPage.start();
    zixuanPage=mainPage.gotoZixuan();
    }

    @Test
    @Order(1)
    void addZixuanTest(){

    ArrayList<String> stocks=zixuanPage.gotoSearch().search("pdd").addZixuan().gotoZixuan().getStocks();
    assertThat(stocks,hasItems("拼多多"));
    }


    @Test
    @Order(2)
    void cancelSelectTest(){

    String toast=zixuanPage.gotoStockinfo().deleteSelect().getToast();
    assertThat(toast, equalTo("已从自选删除"));
    }
    }
  • 作业1
    [I have no name!@izuf60jasqavbxb9efockpz ~]$ netstat -nt | sed 1,2d | awk '{print $6}' | sort | uniq -c
    49 ESTABLISHED
    1 TIME_WAIT

    作业2
    [I have no name!@izuf60jasqavbxb9efockpz ~]$ curl https://testerhome.com 2>/dev/null | grep -b1 "fa fa-diamond" | grep "href" | awk -F "\"" '{print $4}'| grep "topics" | while read line; do count=$(curl https://testerhome.com$line 2>/dev/null | grep -b1 "total-info" | awk -F "<|>" '{print $3}') ; echo $line回复数为$count ;done
    /topics/17292回复数为 5
    /topics/17232回复数为 6
    /topics/17117回复数为 13
    /topics/17066回复数为 8
    /topics/16909回复数为 31
    /topics/16689回复数为 25
    /topics/16556回复数为 38
    /topics/16498回复数为 15
    /topics/16376回复数为 36
    /topics/17251回复数为 7
    /topics/17179回复数为 16
    /topics/17068回复数为 24
    /topics/17004回复数为 16
    /topics/16920回复数为 27
    /topics/16790回复数为 7
    /topics/16605回复数为 12
    /topics/16436回复数为 19

  • 有人遇到过这个报错吗?
    Exception in thread "main" java.nio.charset.MalformedInputException: Input length = 1

  • 谢谢各位了,我现在用的方法比较简单粗暴,但很有效果😁
    def findItem(self,el):
    source = self.driver.page_source
    if el in source:
    return True
    else:
    return False

  • 可以用driver.tap点击酒店对应的坐标实现定位

  • Sikuli还是比较好用的