Saturday, September 23, 2017

How to read xml file and it's node values using c#

Class file:

 [TestMethod]
        public void readXml()
        {
            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.Load("D:\\Data.xml");
            XmlNodeList nodeList = xmlDoc.DocumentElement.SelectNodes("/Testing/Tools");
            string proID = "", pro_name = "", pro_item = "";
            foreach (XmlNode node in nodeList)
            {
                proID = node.SelectSingleNode("Tool").InnerText;
                pro_name = node.SelectSingleNode("Performance").InnerText;
                pro_item = node.SelectSingleNode("Mobile").InnerText;
                // MessageBox.Show(proID + " " + proName + " " + price);
                Console.WriteLine(proID);
                Console.WriteLine(pro_name);
                Console.WriteLine(pro_item);
            }
        }


----------------------------------------------------------------------
Xml file -
-----------------------------------------

Wednesday, September 13, 2017

Providing Online and offline Testing courses for all Types of Testings - Trainer- Contact - Ramesh K +91 9182370643


Proxy setting to browser level using selenium with java



Let's say if your application work with proxy values on your browser, so you need to set the proxy server and port number before invoking the application  so here is the code.


import org.openqa.selenium.Proxy;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.CapabilityType;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.testng.annotations.Test;

public class ProxyTest {

    @Test
    public void testMethod(){
    WebDriver driver;

       String usedProxy = "IPAddress:port";

        Proxy proxy = new org.openqa.selenium.Proxy();
        proxy.setHttpProxy(usedProxy).setFtpProxy(usedProxy).setSslProxy(usedProxy);
        DesiredCapabilities cap = new DesiredCapabilities();
        cap.setCapability(CapabilityType.PROXY, proxy);

        driver = new FirefoxDriver(cap);
       
        driver.get("yoursite.com/");
}
}

TestNG - Can i use the 2 different data providers to same @test methods in TestNG?

public Object [][] dp1 () { return new Object [][] { new Object [] { "a" , "b" }, new Obje...