In this session, you will be learning how to read data from XML File and how XML file is important in Automation.
What is XML File
Difference between XML and HTML
How to read XML File
Please download all codes from below github repository
https://github.com/knowledgeshare-tec...
𝐃𝐨 𝐲𝐨𝐮 𝐰𝐚𝐧𝐭 𝐭𝐨 𝐥𝐞𝐚𝐫𝐧 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐀𝐮𝐭𝐨𝐦𝐚𝐭𝐢𝐨𝐧 𝐢𝐧 𝐯𝐞𝐫𝐲 𝐞𝐚𝐬𝐲 𝐰𝐚𝐲 ?
Learn Selenium in easy way by dividing the concepts in to Module wise. Below are the list of Modules wise learning, each contains max 4 to 5 videos that you can complete in 1 or 2 days.
🅽🅾🆃🅴
You have all practice programs pasted in the description on each video.
You have GitHub Repository where all the programs are stored at one place for your practice.
Links pasted at the end
𝐘𝐨𝐮 𝐜𝐚𝐧 𝐣𝐨𝐢𝐧 𝐛𝐞𝐥𝐨𝐰 𝐆𝐫𝐨𝐮𝐩 𝐟𝐨𝐫 𝐦𝐨𝐫𝐞 𝐮𝐩𝐝𝐚𝐭𝐞𝐬 𝐚𝐧𝐝 𝐟𝐨𝐫 𝐜𝐨𝐥𝐥𝐚𝐛𝐨𝐫𝐚𝐭𝐢𝐨𝐧
/ 4754296501308288
𝐈𝐟 𝐲𝐨𝐮 𝐰𝐚𝐧𝐭 𝐭𝐨 𝐝𝐢𝐬𝐜𝐮𝐬𝐬 𝐨𝐫 𝐬𝐡𝐚𝐫𝐞 𝐨𝐫 𝐠𝐚𝐢𝐧 𝐤𝐧𝐨𝐰𝐥𝐞𝐝𝐠𝐞 𝐨𝐫 𝐭𝐫𝐨𝐮𝐛𝐥𝐞𝐬𝐡𝐨𝐨𝐭 𝐈𝐬𝐬𝐮𝐞𝐬 𝐛𝐲 𝐭𝐚𝐤𝐢𝐧𝐠 𝐡𝐞𝐥𝐩 𝐣𝐨𝐢𝐧 𝐭𝐡𝐞 𝐛𝐞𝐥𝐨𝐰 𝐅𝐨𝐫𝐮𝐦
https://chat.whatsapp.com/Drhb7GEZcrA...
𝐂𝐨𝐫𝐞 𝐉𝐚𝐯𝐚 𝐁𝐚𝐬𝐢𝐜 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭
• Core Java
𝐎𝐎𝐏𝐒 𝐂𝐨𝐧𝐜𝐞𝐩𝐭𝐬 𝐏𝐥𝐚𝐲𝐥𝐢𝐬𝐭
• OOPS Concepts in Java
𝐅𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤 𝐏𝐫𝐞-𝐫𝐞𝐪𝐮𝐢𝐬𝐢𝐭𝐞𝐬
• Framework Pre-requisites
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐁𝐚𝐬𝐢𝐜 𝐏𝐫𝐨𝐠𝐫𝐚𝐦𝐬 𝐏𝐫𝐚𝐜𝐭𝐢𝐜𝐞
https://github.com/knowledgeshare-tec...
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐒𝐞𝐥𝐞𝐧𝐢𝐮𝐦 𝐅𝐫𝐚𝐦𝐞𝐰𝐨𝐫𝐤 𝐝𝐞𝐬𝐢𝐠𝐧 𝐜𝐨𝐧𝐜𝐞𝐩𝐭𝐬
https://github.com/knowledgeshare-tec...
𝐆𝐢𝐭𝐇𝐮𝐛 𝐑𝐞𝐩𝐨 𝐟𝐨𝐫 𝐂𝐨𝐫𝐞 𝐉𝐚𝐯𝐚 𝐩𝐫𝐨𝐠𝐫𝐚𝐦𝐬 𝐩𝐫𝐚𝐜𝐭𝐢𝐜𝐞
https://github.com/knowledgeshare-tec...
Program :
package xml_Read_Write;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathFactory;
import org.openqa.selenium.WebDriver;
import org.openxmlformats.schemas.drawingml.x2006.main.impl.CTSystemColorImpl;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
public class ReadXML {
public static void main(String[] args)
{
System.setProperty("ExecutionEnv", "stage");
String web_url=ReadXML.getTestData("WEB","application_url");
System.out.println("Recieved Web URL is : " + web_url);
System.setProperty("ExecutionEnv", "stage");
String db_url=ReadXML.getTestData("DB", "DB_Conn_String");
System.out.println("Recieved DB URL is : " + db_url );
/*
WebDriver driver = null; driver.get(db_url);
*/
}
private static String getTestData(String SectionName, String NodeName)
{
String env=System.getProperty("ExecutionEnv");
//System.out.println("Environment is :" + env );
String path ="Project/"+SectionName+"/"+env+"/"+NodeName;
//System.out.println("Path is : " +path );
File XmlFile=new File("Environments.xml");
String final_value = null;
DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder;
Document doc;
NodeList nodeList;
Node node;
XPath xPath;
try
{
dBuilder=dbFactory.newDocumentBuilder();
doc=dBuilder.parse(XmlFile);
doc.getDocumentElement().normalize();
xPath=XPathFactory.newInstance().newXPath();
nodeList=(NodeList) xPath.compile(path).evaluate(doc, XPathConstants.NODESET);
}
catch(Exception e)
{
return null;
}
for(int temp=0;tempLTnodeList.getLength();temp++)
{
node=nodeList.item(temp);
if(node.getNodeName().equals(NodeName))
{
final_value=node.getTextContent().trim();
}
}
return final_value;
}
}
41# How to read data from XML File II Maintaining Environment and DB details in XML File || Selenium
#SeleniumAutomation
#ReadXMLFile
#HowtoReadXMLFile
#SeleniumAutomation
#KnowledgeShare