23

Let's say we have this website https://www.coinichiwa.com/ which has a BET AMOUNT input box. It's html is:

<input autocomplete="off" id="betFa" name="a" maxlength="20" value="0.00000000" class="betinput" style="">

I need to add some value into it. Here is my code:

browser = webdriver.Firefox()
browser.get('https://www.coinichiwa.com')

browser.find_element_by_id("betFa").send_keys("0.00000005")
print browser.find_element_by_xpath("//input[contains(@id,'betFa')]").text

But it's neither setting it's value to "0.00000005" nor it printing the value of input.

I'm not sure what's going wrong. Can you suggest? Why it's not working?

1 Answer 1

33

You need to clear() the text input first:

bet_fa = browser.find_element_by_id("betFa")
bet_fa.clear()
bet_fa.send_keys("0.00000005")

As for the your second problem - this is an input and the value you enter into it is kept inside the value attribute, not the text. Use get_attribute() method:

browser.find_element_by_xpath("//input[contains(@id,'betFa')]").get_attribute('value')
Sign up to request clarification or add additional context in comments.

4 Comments

thanks, it worked like charm but one more issue... how do i get <div style="float:left;font-size:14px;width:120px;height:25px;border-color:#ACACAC;background-color:#EAEAEA;color:black"><div style="margin:4px;" id="jukeamt">0.00100101</div></div> the jukeamt <div>'s inside value?
@CracLock okay, If I understood the question correctly: driver.find_element_by_id('jukeamt').text.
ah, not working this way. tried but it's returning empty
@CracLock well, it is a separate problem, definitely solvable - please consider asking a separate question if you need help and throw me a link here in comments. Thank you for understanding.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.