Showing posts with label Automations. Show all posts
Showing posts with label Automations. Show all posts

2017-06-01

Set Invisible Element to Visible Using Javascript in Selenium

Automation with selenium requires target element to be set visible.
While when element is designed to be displayed: none or visibility = hidden,  we have to manually set element css style to be visible using Javascript for selenium to catch on.

Here is the code:

IWebElement checkbox = driver.FindElement(By.Id("identifierOrOther"));
IJavaScriptExecutor executor = (IJavaScriptExecutor)driver;
executor.ExecuteScript("arguments[0].style.display = 'block'", checkbox);
checkbox.Click();


style.display = block can be replaced any other code, just inspect the hidden element and find out hidden css line.




2017-05-13

Deal with Annoying Popup New Tabs in Selenium

When I was trying to scraping a website using selenium webdriver, everytime I navigate to new url, a third party annoying advertisement page opened which I cannot block it out.

So I found out WindowHandler if Selenium which quite userful.

Simpley here is how I make it.


C#
public static void RemoveAdd()
{

    if (driver.WindowHandles.Count() > 1)
    {
        do
        {
         driver.SwitchTo().Window(driver.WindowHandles.Last());   
         driver.Close();   
         driver.SwitchTo().Window(driver.WindowHandles.Last());         
         } while (driver.WindowHandles.Count() > 1)         
     }

}





2017-04-17

Why Need Automation Test

Why:

1. Reduce cost & time
Execution of similar or same test case with different test data can be easily programmed into automation test which could be done in short period of time, rather than a tester manually execute these test cases for days.


2. Improve accuracy and reliability
Testers are human, the longer he/she works, the more possibility that he/she will make mistakes in test execution, such as missing out input or wrongful input.


When
Avoid duplicate test, when code repeated

Regression test

Pre-requisite action



How
Visual Studio + Selenium + Selenium Chrome + NUnit + ExcelDataReader

or

Java + JUnit






Setup VNC on Ubuntu 20.04

  sudo apt update sudo apt install xfce4 xfce4-goodies sudo apt install tigervnc-standalone-server sudo apt install tightvncserver vncserver...