Unable to click on Button using Selenium Python
I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:
<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>
python selenium selenium-webdriver xpath css-selectors
add a comment |
I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:
<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>
python selenium selenium-webdriver xpath css-selectors
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
1
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31
add a comment |
I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:
<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>
python selenium selenium-webdriver xpath css-selectors
I'm trying to click on this button to go to the next page, but for some reason, I'm unable to. I tried xpath, css, and class selectors as well as the data-trekkie-id attribute, but nothing I have tried worked. Any help? Code below:
<div class="step__footer" data-step-footer="">
<button name="button" type="submit" class="step__footer__continue-btn btn " data-trekkie-id="continue_to_shipping_method_button" aria-busy="false">
<span class="btn__content">
Continue to shipping method
</span>
</button>
</div>
python selenium selenium-webdriver xpath css-selectors
python selenium selenium-webdriver xpath css-selectors
edited Nov 15 '18 at 10:56
DebanjanB
43k94383
43k94383
asked Nov 15 '18 at 0:58
Frank DiGiacomo KnarF THUNDER Frank DiGiacomo KnarF THUNDER
74
74
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
1
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31
add a comment |
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
1
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
1
1
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31
add a comment |
2 Answers
2
active
oldest
votes
As per the HTML to invoke click()
method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:
Using
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()
Using
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
add a comment |
This should work:
driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()
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%2f53310984%2funable-to-click-on-button-using-selenium-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
As per the HTML to invoke click()
method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:
Using
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()
Using
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
add a comment |
As per the HTML to invoke click()
method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:
Using
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()
Using
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
add a comment |
As per the HTML to invoke click()
method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:
Using
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()
Using
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
As per the HTML to invoke click()
method on the button with text as Continue to shipping method you need to induce WebDriverWait and you can use either of the following solutions:
Using
CSS_SELECTOR
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button.step__footer__continue-btn.btn[data-trekkie-id='continue_to_shipping_method_button']>span.btn__content"))).click()
Using
XPATH
:
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, "//button[@class='step__footer__continue-btn btn' and @data-trekkie-id='continue_to_shipping_method_button']/span[@class='btn__content']"))).click()
Note : You have to add the following imports :
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
answered Nov 15 '18 at 10:57
DebanjanBDebanjanB
43k94383
43k94383
add a comment |
add a comment |
This should work:
driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()
add a comment |
This should work:
driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()
add a comment |
This should work:
driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()
This should work:
driver.find_element_by_xpath("//*[contains(local-name(), 'button') and contains(@class, 'step__footer__continue-btn')]").click()
answered Nov 15 '18 at 12:19
AlichinoAlichino
7801617
7801617
add a comment |
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%2f53310984%2funable-to-click-on-button-using-selenium-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
any error or exception when you click to it?
– thanh le
Nov 15 '18 at 1:02
1
That isn't code; that's html, and it's only half of the equation. Show us the code.
– John Gordon
Nov 15 '18 at 1:31