zoukankan      html  css  js  c++  java
  • [Selenium] Selenium 疑难杂症

    1. jsclick 也不管用

    Actions action = new Actions(driver);
    WebElement theRow = page.getInvisibleElement();
    action.moveToElement(theRow).perform();
    page.getInvisibleElement().click(); 或page.getInvisibleElement().click();再获取一遍theRow

    2.Issue : Cannot get text of a hidden element, SeleniumUtil. scrollIntoView(element) also doesn’t work for the element

    Solution :  JavaScript to get the text of hidden element.

    Code :

    WebElement tickerEl = el.findElement(By.cssSelector("td.auto-left"));

    String tickerName = (String) ((JavascriptExecutor) driver).executeScript("return jQuery(arguments[0]).text();", tickerEl);

    String tickTmp =StringUtils.trim(tickerName);

    logger.info("Ticker : "+tickTmp);

    3.Issue : Search function doesn't work sometime after we input the search condition, I guess it may cause by the realization method, the UI may only check the search condition each period of time,

    If the input miss the check,  we need to input again

     Solution : If the drop down list doesn’t display the first time after inputting search condition, clear it and input the search condition again

    4.Issue : Cannot get text of the columns which doesn’t show out, we need to drag the scroll bar to make it display when do testing manually.

    Solution :  Use SeleniumUtil.scrollIntoView(driver, el);

    Code :

    for (WebElement el : columns) {

        if(!(el.isDisplayed())){

            SeleniumUtil.scrollIntoView(driver, el);

            }

        logger.info("Column : " + el.getText());

    … …

    }

    5.问题:元素定位方法没有错,但却定位不到元素

    解决方法:发现网页有2个frame,需要定位的元素在左侧frame中,需要先跳转到左边的frame

    代码:

     

    6.问题:“确认”按钮通过class name或 css定位不到

     

    解决方法:

    通过xpath 定位,再点击

  • 相关阅读:
    2020.11.21日记
    Miller-Rabin质数测试
    Deepin配置记录
    shell
    module load
    vma
    DRDI
    Android.mk
    AEE
    阿里云下配置二级域名的解析设置
  • 原文地址:https://www.cnblogs.com/feifeidxl/p/4598157.html
Copyright © 2011-2022 走看看