“Temukan elemen di selenium” Kode Jawaban

Temukan elemen di selenium

//required imports 
WebDriver driver = new ChromeDriver();
WebElement objWE;
//There are many way most common are id and xpath
objWE = driver.findElement(By.id("String of id attribute"));
//To find the xpath easily hit F12 and right click the element you want
//and copy xpath then paste it
objWE = driver.findElement(By.xpath("//*[@id="search"]/div[2]/div[6]/div[1]/div/div"));
GelatinousMustard

cara menemukan selenium

elementcss= driver.findElement(By.cssSelector('div.nav-search-input'))
Panicky Pintail

Temukan elemen di selenium

#In Python

#Let's say that we want to locate the h1 tag in this HTML:
#<html>
#    <head>
#        ... some stuff
#    </head>
#    <body>
#        <h1 class="someclass" id="greatID">Super title</h1>
#    </body>
#</html>

h1 = driver.find_element_by_name('h1')
h1 = driver.find_element_by_class_name('someclass')
h1 = driver.find_element_by_xpath('//h1')
h1 = driver.find_element_by_id('greatID')
Fun Bee

Jawaban yang mirip dengan “Temukan elemen di selenium”

Pertanyaan yang mirip dengan “Temukan elemen di selenium”

Lebih banyak jawaban terkait untuk “Temukan elemen di selenium” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya