Use the method below to collect one or several elements in the DOM.
Tip
If you can't access an element but it is on the page, make sure that it is not inside an iframe.
If it is inside an iframe you need to go into the iframe and search inside. Click here for more information.
Parameter
Description
selector
the identifier that will be used to fetch the element.
by
the type of selector
Operations with the element
When the element is returned you can click on it or send a value to it
# Import for the By enum.frombotcity.webimportBy# searching for an element by ID.username_field=bot.find_element(selector='username',by=By.ID)# clicking on the element.username_field.click()# sending a value to the element.username_field.send_keys('my_username')# searching for several elements that contain in their class name the value 'container.divs=bot.find_elements(selector='container',by=By.CLASS_NAME)print(len(divs))
// Import for the By enum.importorg.openqa.selenium.By;// searching for an element by ID.WebElementusernameField=findElement(By.id("username"));// clicking on the element.usernameField.click();// sending a value to the element.usernameField.sendKeys("my_username");// searching for several elements that contain in their class name the value 'container.List<WebElement>divs=findElements(By.className("container"));System.out.println(divs.size());