Quality Testing

Quality is delighting customers

How to record page source (meta title and meta description) with selenium ide(chrome add-on) ???

I want to record page source (meta title and meta description) with selenium ide(chrome add-on) and check it on daily basis that's why i need to create selenium..i try so many things but not work :( please any one have code than please provide me

Views: 58

Reply to This

Replies to This Discussion

Hi Hanshika,

You can get the Page title & meta descriptions in selenium using the HTML tags & simple gettitle() function in the script like I did in the code below. Also, almost every software testing company uses this code to get the attributes of any HTML element of the web page.

Code: 

package sample;

import org.openqa.selenium.By;

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

public class MetaData {

public static void main(String[] args) {

System.setProperty("webdriver.chrome.driver", "C:\\selenium\\chromedriver.exe");

WebDriver driver = new ChromeDriver();

driver.manage().window().maximize();

driver.get("https://www.timeanddate.com/");

System.out.println(driver.getTitle()); System.out.println(driver.findElement(By.xpath("//meta[@name='description']")).getAttribute("content"));

   }

}

Please do let me know in case you are having any trouble running or understanding this code.

Thanks

RSS

TTWT Magazine


Advertisement

Advertisement

Advertisement

Advertisement

© 2020   Created by Quality Testing.   Powered by

Badges  |  Report an Issue  |  Terms of Service