script 1
package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
String tagname = driver.findElement(By.id("gbqfba")).getTagName();
System.out.println(tagname);
}
}
Output:-
button
getTagName() method Gets the tag name of the element.
Above script gets tag name of google search button.
script2
package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.yahoo.co.in");
String tagname = driver.findElement(By.name("p")).getTagName();
System.out.println(tagname);
}
}
Output:-
input
Above script gets tag name of search textbox from yahoo.co.in website.
package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com");
String tagname = driver.findElement(By.id("gbqfba")).getTagName();
System.out.println(tagname);
}
}
Output:-
button
getTagName() method Gets the tag name of the element.
Above script gets tag name of google search button.
script2
package selenium_examples;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Test {
public static void main(String[] args) {
WebDriver driver = new FirefoxDriver();
driver.get("http://www.yahoo.co.in");
String tagname = driver.findElement(By.name("p")).getTagName();
System.out.println(tagname);
}
}
Output:-
input
Above script gets tag name of search textbox from yahoo.co.in website.
No comments:
Post a Comment