So here's the segment of the website that I'm working with. Specifically I wanna obtain the value from . I can access the span class using best_offer = driver.find_element_by_class_name('showBestOffer')
in Selenium, is there a way I can fetch the value inside the tag?
<div id="363858864519-bestOffer-simple"><div style="display: flex; align-items: center; justify-content: center;"><span ><b>Best Offer Accepted Price: </b></span><span ><span ><input type="submit" value="15.00 USD"></span></span></div></div>
CodePudding user response:
best_offer = driver.find_element_by_class_name('showBestOffer').get_text()
CodePudding user response:
You can try this solution
span = driver.find_element(By.CSS_SELECTOR,"span[class='showBestOffer']")
input = span.find_element(By.TAG_NAME, "input")
bestOffer = input.get_attribute("value")
CodePudding user response:
Using xpath
input = driver.findElement(By.xpath('//span[@]/input'))
val = input.get_attribute("value")