TESTEVERYTHING

Sunday, 5 February 2017

EXTRACT CSS PROPERTY VLAUE OF PSEUDO ELEMENTS CONTAINING :after/:before CSS TAG USING JAVASCRIPT IN WEBDRIVER :

We cannot extract css properties of pseudo elements using web driver commands such as ‘.getPropertyValue’ . For this, we need to use JavaScript and execute a js script in selenium web driver.


A CSS pseudo-element is used to style specified parts of an element.
   For example, it can be used to:
   Style the first letter, or line, of an element
   Insert content before, or after, the content of an element

ISSUE:



In above scenario, we need to get the text “Internal Use Only” from UI which is associated with an Anchor (a) tag in DOM with :after CSS tag. The text is present in “content” Style Property as shown in right highlighted box.

The :after CSS tag cannot be located directly using web driver and thus required text cannot be retrieved simply by using .getPropertyValue() function in selenium.

To achieve this, a javascript needs to be executed in our selenium code :

WebElement elementObj = driver.findElement(By.xpath("<YourXpath>"));
String pseudoElementText = ((JavascriptExecutor)driver).executeScript("return window.getComputedStyle(arguments[0],':after').getPropertyValue(content');", elementObj).toString();

System.out.println(pseudoElementText);


In same way we can extract another properties values as well.

Thanks


Thursday, 1 December 2016

Useful Tips in Mobile Automation






  •  How to use ADB (Android Debug Bridge) over wifi | ...
  •  How to know app package and activities information...
  • Webdriver compare data/css between two pages
  • How to Re-Sign an ios App from an External Develop...
  • To know all devices connected to machines / simula...
  • Automation Testing of Android app on device using ...
  • Calabash ios installation steps
  • Calabash-ios commands
  • INSTALL IDEVICEINSTALLER ON MAC MACHINE
  • MOBILE WEB/APPLICATION AUTOMATION INSTALLATION GUI...
  • Easiest Way to Get the Crash Logs in ios 
  • Blocking Internet for Specific Apps
  • Business Models: How Does Mobile App Makes Money? 
  • Projecting Android Screen on to Your PC
  • Bandwidth Throttling Using Fiddler 
  • ADB commands with examples
  • Android Screencast: Android screen to Windows PC
  • Limiting Internet Speed On Your Mobile Device (Ban... 
  •  Wireless ADB
  •  Recording Android Device Screen using ADB
  •  Securing Your Smartphones
  •  Mobile Application Testing –Think Before You Test
  • Android on Windows
  • Wednesday, 16 November 2016

    Actual differences between Explicit and Implicit Waits

    Hi All,

    As i have already mentioned the differences Explicit and Implicit Waits in my earlier post but now we will see the actual results. there will be two conditions we can think of it what will happen if implicit wait is greater than explicit wait OR  implicit wait is lower than explicit wait

    lets see what will happen


    Condition 1: implicit wait is greater than explicit wait

               implicitlyWait = 10 seconds
                explicitWait = 2 seconds
                ///////////////////////////////////////
                public static void main(String[]args) {
                FirefoxDriver driver = new FirefoxDriver();
                driver.manage().window().maximize();
                driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
                driver.get("https://www.google.com");
                try {
                            Date date = new Date();
                            System.out.println(" before " + new Timestamp(date.getTime()));
                            WebDriverWait wait = new WebDriverWait(driver, 2);
                            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(text(),'NOT FOUND ELEMENT')]")));
                } catch (Exception e) {
                            // TODO Auto-generated catch block
                            Date date = new Date();
                            System.out.println(" after " + new Timestamp(date.getTime()));
                            e.printStackTrace();
                }


    /////////////////////////////////

    let see the output in console:   taking 10 seconds

    before 2016-11-16 16:24:33.128
    after 2016-11-16 16:24:43.321

    Condition 2: implicit wait is lower than explicit wait
               implicitlyWait = 2 seconds
                explicitWait = 10 seconds
                ///////////////////////////////////////
                public static void main(String[]args) {
                FirefoxDriver driver = new FirefoxDriver();
                driver.manage().window().maximize();
                driver.manage().timeouts().implicitlyWait(2, TimeUnit.SECONDS);
                driver.get("https://www.google.com");
                try {
                            Date date = new Date();
                            System.out.println(" before " + new Timestamp(date.getTime()));
                            WebDriverWait wait = new WebDriverWait(driver, 10);
                            wait.until(ExpectedConditions.presenceOfElementLocated(By.xpath("//div[contains(text(),'NOT FOUND ELEMENT')]")));
                } catch (Exception e) {
                            // TODO Auto-generated catch block
                            Date date = new Date();
                            System.out.println(" after " + new Timestamp(date.getTime()));
                            e.printStackTrace();
                }


    /////////////////////////////////

    let see the output in console:   taking 10 seconds

    before 2016-11-16 16:26:53.355
     after 2016-11-16 16:27:03.53

    Which one is right ?

    Translate







    Tweet