Selenium cannot find form element in google calendar (Python)
I am attempting to import calendar events to google calendar through a csv file using Selenium and Python. I am unable to select the form element to input my file path into google. I have tried finding the element by xpath, cssselector and class name and I get the same error every time:
selenium.common.exceptions.NoSuchElementException: Message: no such
element: Unable to locate element
fileElem = browser.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form')
The example xpath shown above was copied directly through google chrome. Any ideas why I can't get this to work? Thanks! Here's the picture of the element and the HTML code.
python selenium gcal
add a comment |
I am attempting to import calendar events to google calendar through a csv file using Selenium and Python. I am unable to select the form element to input my file path into google. I have tried finding the element by xpath, cssselector and class name and I get the same error every time:
selenium.common.exceptions.NoSuchElementException: Message: no such
element: Unable to locate element
fileElem = browser.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form')
The example xpath shown above was copied directly through google chrome. Any ideas why I can't get this to work? Thanks! Here's the picture of the element and the HTML code.
python selenium gcal
add a comment |
I am attempting to import calendar events to google calendar through a csv file using Selenium and Python. I am unable to select the form element to input my file path into google. I have tried finding the element by xpath, cssselector and class name and I get the same error every time:
selenium.common.exceptions.NoSuchElementException: Message: no such
element: Unable to locate element
fileElem = browser.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form')
The example xpath shown above was copied directly through google chrome. Any ideas why I can't get this to work? Thanks! Here's the picture of the element and the HTML code.
python selenium gcal
I am attempting to import calendar events to google calendar through a csv file using Selenium and Python. I am unable to select the form element to input my file path into google. I have tried finding the element by xpath, cssselector and class name and I get the same error every time:
selenium.common.exceptions.NoSuchElementException: Message: no such
element: Unable to locate element
fileElem = browser.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form')
The example xpath shown above was copied directly through google chrome. Any ideas why I can't get this to work? Thanks! Here's the picture of the element and the HTML code.
python selenium gcal
python selenium gcal
edited Nov 16 '18 at 2:25
Mihai Chelaru
2,377101323
2,377101323
asked Nov 16 '18 at 1:38
Luke O'MalleyLuke O'Malley
82
82
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
add a comment |
Ok, so I tried it myself and found out that when you open that specific URL, it redirects you to the google sign in page, which doesn't have an element with your XPath. So what you could do is just go to the sign in page and find the forms for username and password, then use sendkeys()
to type in your username/password. Then it should redirect you to the right page and the XPath will work.
Use this code:
from selenium import webdriver
import time
d = webdriver.Chrome("executable file path")
d.get("https://calendar.google.com/calendar/r/settings/export")
d.find_element_by_xpath('//*[@id="identifierId"]').send_keys("your email")
d.find_element_by_xpath('//*[@id="identifierNext"]').click() # Next button
time.sleep(0.5) # Sometimes the time it takes to load the next page will cause the next line to fail
d.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("your password")
d.find_element_by_xpath('//*[@id="passwordNext"]').click() # Next button
d.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form/label') #Now you have the proper element
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330261%2fselenium-cannot-find-form-element-in-google-calendar-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
add a comment |
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
add a comment |
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")
change the xpath with //form[@jsname="GBqgNb"]//input
but if still unable to locate, try add WebDriverWait()
# wait 5 second
fileElem = WebDriverWait(driver, 5).until(EC.presence_of_element_located((By.XPATH , '//form[@jsname="GBqgNb"]//input')))
fileElem.send_keys("/path/to/file")
answered Nov 16 '18 at 3:35
ewwinkewwink
12.2k22440
12.2k22440
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
add a comment |
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
Thanks a lot! Using WebDriverWait solved my problem!
– Luke O'Malley
Nov 16 '18 at 19:00
add a comment |
Ok, so I tried it myself and found out that when you open that specific URL, it redirects you to the google sign in page, which doesn't have an element with your XPath. So what you could do is just go to the sign in page and find the forms for username and password, then use sendkeys()
to type in your username/password. Then it should redirect you to the right page and the XPath will work.
Use this code:
from selenium import webdriver
import time
d = webdriver.Chrome("executable file path")
d.get("https://calendar.google.com/calendar/r/settings/export")
d.find_element_by_xpath('//*[@id="identifierId"]').send_keys("your email")
d.find_element_by_xpath('//*[@id="identifierNext"]').click() # Next button
time.sleep(0.5) # Sometimes the time it takes to load the next page will cause the next line to fail
d.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("your password")
d.find_element_by_xpath('//*[@id="passwordNext"]').click() # Next button
d.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form/label') #Now you have the proper element
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
add a comment |
Ok, so I tried it myself and found out that when you open that specific URL, it redirects you to the google sign in page, which doesn't have an element with your XPath. So what you could do is just go to the sign in page and find the forms for username and password, then use sendkeys()
to type in your username/password. Then it should redirect you to the right page and the XPath will work.
Use this code:
from selenium import webdriver
import time
d = webdriver.Chrome("executable file path")
d.get("https://calendar.google.com/calendar/r/settings/export")
d.find_element_by_xpath('//*[@id="identifierId"]').send_keys("your email")
d.find_element_by_xpath('//*[@id="identifierNext"]').click() # Next button
time.sleep(0.5) # Sometimes the time it takes to load the next page will cause the next line to fail
d.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("your password")
d.find_element_by_xpath('//*[@id="passwordNext"]').click() # Next button
d.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form/label') #Now you have the proper element
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
add a comment |
Ok, so I tried it myself and found out that when you open that specific URL, it redirects you to the google sign in page, which doesn't have an element with your XPath. So what you could do is just go to the sign in page and find the forms for username and password, then use sendkeys()
to type in your username/password. Then it should redirect you to the right page and the XPath will work.
Use this code:
from selenium import webdriver
import time
d = webdriver.Chrome("executable file path")
d.get("https://calendar.google.com/calendar/r/settings/export")
d.find_element_by_xpath('//*[@id="identifierId"]').send_keys("your email")
d.find_element_by_xpath('//*[@id="identifierNext"]').click() # Next button
time.sleep(0.5) # Sometimes the time it takes to load the next page will cause the next line to fail
d.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("your password")
d.find_element_by_xpath('//*[@id="passwordNext"]').click() # Next button
d.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form/label') #Now you have the proper element
Ok, so I tried it myself and found out that when you open that specific URL, it redirects you to the google sign in page, which doesn't have an element with your XPath. So what you could do is just go to the sign in page and find the forms for username and password, then use sendkeys()
to type in your username/password. Then it should redirect you to the right page and the XPath will work.
Use this code:
from selenium import webdriver
import time
d = webdriver.Chrome("executable file path")
d.get("https://calendar.google.com/calendar/r/settings/export")
d.find_element_by_xpath('//*[@id="identifierId"]').send_keys("your email")
d.find_element_by_xpath('//*[@id="identifierNext"]').click() # Next button
time.sleep(0.5) # Sometimes the time it takes to load the next page will cause the next line to fail
d.find_element_by_xpath('//*[@id="password"]/div[1]/div/div[1]/input').send_keys("your password")
d.find_element_by_xpath('//*[@id="passwordNext"]').click() # Next button
d.find_element_by_xpath('//*[@id="YPCqFe"]/div/div/div/div[1]/div[1]/div/form/label') #Now you have the proper element
edited Nov 16 '18 at 3:23
answered Nov 16 '18 at 3:12
user8969265user8969265
13
13
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
add a comment |
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
Thanks a lot for your help! However, I was still unable to locate the element using the xpath. Did that work for you when you tried it?
– Luke O'Malley
Nov 16 '18 at 19:01
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53330261%2fselenium-cannot-find-form-element-in-google-calendar-python%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown