Issue
How do I send my string, imei
it's currently attached into a string which is visible in my code.
For finding the xpath function I attached it into a variable assuming that it would allow the send_keys
property but it didn't.
import time
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
imei = 'id'
xpath = 'xpath here'
options = Options()
options.add_experimental_option('w3c', True)
options.add_experimental_option("detach", True)
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()), options=options)
driver.get("https://www.t-mobile.com/resources/bring-your-own-phone")
time.sleep(2)
elem = driver.find_element_by_xpath(xpath).click()
elem.send_keys(imei)
XPath is also in a string because it's extremely lengthy and would make it very difficult to view. Nonetheless, it works still. The service goes to the webpage and clicks the path but it does not enter the value I want to input which is imei
.
Solution
elem = driver.find_element_by_xpath(xpath).click()
This is the problem. You're assigning elem to the result of the click()
function, which doesn't return anything, therefore it returns None
.
Assign elem to the element, then call click()
separately as follows:
elem = driver.find_element_by_xpath(xpath)
elem.click()
elem.send_keys(...)
Answered By - John Gordon
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.