Selenium how to access two controls of same css class
You can access first label via:
css=div[class='control-group'] label[class='control-label']:contains('Email')
You can access second lavel via:
css=div[class='control-group'] label[class='control-label']:contains('Password')
Use these with command assertElementPresent, "contains" in element locator allows you to verify text in it.
Also you can use xpath:
//div[@class='control-group']//label[@class='control-label'][text()='Email']
//div[@class='control-group']//label[@class='control-label'][text()='Password']
Usually maxlength property is set as attribute of the input, but i can't see it in your html code.. But you can try:
storeAttribute (Selenium IDE's command) and as target you can use xpath:
/div[@class='control-group']//label[@class='control-label'][text()='Email']/@maxlength
save it to some var (eg set to the value field smthg like attLength) and then echo this var like: Selenium IDE's command echo and as put to the target field ${attLength} How to access the second element that has the same class name in selenium using java
You can use xpath indexing option.
By.xpath("(//input[@name='Button'])[2]")
How to select button inside of multiple classes with selenium python?
Find elements instead by CSS selector:
driver.find_element(By.CSS_SELECTOR, ".card-summer_1 .button-class")
How can I select multiple button with same id in python selenium
Though both the buttons are having the same value i.e. 1 for the id
attribute but they are located at different location within the Viewport and you have you select i.e. invoke click()
on them individually.
The desired element is a Ember.js enabled element, so ideally, to click on the element you need to induce WebDriverWait for the element_to_be_clickable()
and you can use either of the following Locator Strategies:
XPath
to click the first element:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='bedroomNum']//div[@id='1']/span[text()='1']"))).click()
CSS_SELECTOR
to click the first element:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#bedroomNum div#1 > span"))).click()
XPath
to click the second element:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//div[@id='bathroomNum']//div[@id='1']/span[text()='1']"))).click()
CSS_SELECTOR
to click the second element:WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "div#bathroomNum div#1 > span"))).click()
Note: You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Related Topics
Centering in CSS, When The Object Is Larger Than The Viewport
Pseudo Element Across Multiple Lines to Create a Continuous Underline Animation
How to Have Scrollbar When Position Is Negative
Styles Based on Number of Children
CSS Transform Scale to Background Image
Internet Explorer 8 and Checkbox CSS Problem
Resource Interpreted as Stylesheet But Transferred with Mime Type Text Plain Issue
How to Align a Button to The Far Right in Mui Appbar
How to Select <A> Only When There's No Text Around It
How to Make CSS Grid Last Row to Take Up Remaining Space
How to Keep CSS Style for Only One Element
What Exactly Happens When a Browser Doesn't Support Media Queries
Is There an Equivalent to Jquery's: First Selector in CSS3
Bootstrap 4 Float-Right Not Working with The Navbar
Rails 3 - Referencing a CSS Class to Form Elements in an Object Dot Style
Background Images Not Showing in Ie11
Dynamically Changing Font, Font-Size, Font-Color, and So on in Vaadin Flow Web Apps