需要在Selenium Python中成功输入文本之前点击文本输入区域。

huangapple go评论80阅读模式
英文:

Need to click text entering area before enter text successfully in selenium python

问题

I need to entering text in a text entering area. my command is:

self.driver.find_element_by_xpath(f"{self.plateId_input}").send_keys(plateId)

but I have found out issue this command does not work. I have to issue the same command twice. The first time is to click the text area, so the area is ready then issue the command and the text is entered successfully. My question is is there other way to perform this task? issue the command twice does not seems like a good practice.

英文:

I need to entering text in a text entering area. my command is:

self.driver.find_element_by_xpath(f"{self.plateId_input}").send_keys(plateId)

but I have found out issue this command does not work. I have to issue the same command twice. The first time is to click the text area, so the area is ready then issue the command and the text is entered successfully. My question is is there other way to perform this task? issue the command twice does not seems like a good practice.

答案1

得分: 2

element = self.driver.find_element_by_xpath(self.plateId_input)
element.click()
element.send_keys(plateId)

英文:
element = self.driver.find_element_by_xpath(self.plateId_input)
element.click()
element.send_keys(plateId)

huangapple
  • 本文由 发表于 2023年5月7日 21:46:23
  • 转载请务必保留本文链接:https://go.coder-hub.com/76194314.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定