Unable to send_keys to webelement covered by tool-tip

Viewed 60

I try to fill price to the input element. I have tried many ways but they are failed and I realized that it may be covered by another element. While I move my mouse point to the field, it shows a tooltip automatically. And I also see some HTML code lines appears in the inspection box.

Picture1: my screen when I do not point my mouse to that field.

i

Picture 2: my screen when I move the mouse point to that field

i

And here are some of my attempts:

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
driver.execute_script('arguments[0].innerHTML = "100000";', price)

Result: do nothing without error

or

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
browserdriver.execute_script("$(arguments[0]).click();", price)
price.send_keys("10000")

or

price=WebDriverWait(browserdriver, 10).until(EC.element_to_be_clickable((By.XPATH,"//input[@id='inputProductPrice']")))
price.click()
price.send_keys("10000")

or

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
price.click()
price.send_keys("10000")

or

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
actions.move_to_element(price).click(price).perform()
price.send_keys("10000")

I am sure that the XPath is proper and that element is on screen because I can send_keys to the similar field in that row (the field named "2" with blue highlight box in Picture 1).

html:

<div class="col-md-2">
                            <input type="text" class="form-control" placeholder="Nhập giá" id="inputProductPrice" title="" data-toggle="tooltip" data-original-title="(Trên 8.000 VNĐ)" data-bind="moneyMask: ProductPriceForAll">
                        </div>

Pls, help me to overcome this constraint. Thanks

Added words: some fields above this field also have the some tool-tip structure but I can fill in easily and successfully by some of above solutions. But I do not know why this field becomes a strong constraint. For example this field (blue highlight box): picture 3

2 Answers

You should try using ActionChains and move_to_element_with_offset:

action = ActionChains(browserdriver)
price = WebDriverWait(browserdriver, 10).until(EC.element_to_be_clickable((By.XPATH,"//input[@id='inputProductPrice']")))
action.move_to_element_with_offset(price, 5, 5)
action.click().perform()

You can play with the offset to find the area that is clickable...

Hope this helps you!

I don't know why send_keys("100000") is not working.However if you are using JS executor try to update placeholder or value attribute.

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
browserdriver.execute_script('arguments[0].placeholder = "100000";', price)

Or

price=browserdriver.find_element_by_xpath("//*[@id='inputProductPrice']")
browserdriver.execute_script('arguments[0].value = "100000";', price)
Related