How to click this button on this URL using selenium and Python?

John Pham
from selenium import webdriver
from selenium.webdriver import ChromeOptions
from selenium.webdriver.common.keys import Keys
import configparser
from selenium.webdriver import ActionChains
import time
import os


class SeleniumConfig():

    def __init__(self):
        config = configparser.ConfigParser()
        self.absolute = "C:\\Program Files (x86)\\chromedriver.exe"
        options = webdriver.ChromeOptions()
        options.add_argument("--start-maximized")
        self.driver = webdriver.Chrome(self.absolute, options=options)

    def jupiter_1(self):
        self.driver.get('http://jupiter.cloud.planittesting.com')
        self.driver.find_element_by_id("nav-contact").click()
        time.sleep(5)
        form = self.driver.find_element_by_class_name(
            "btn-contact btn btn-primary") # my issue seems to start at the submit button
        time.sleep(5)
        self.driver.quit()

enter image description here

I'm not sure why i'm not able to use the class name, as the inspection says it is

My error:

selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":".btn-contact btn btn-primary"}
  (Session info: chrome=87.0.4280.141)
Arundeep Chohan
self.driver.find_element_by_css_selector(".btn-contact.btn.btn-primary")

Spaces in class names need to be replaced with . in order for proper xpathing.

Also try not to use time.sleep() and use the following to allow the page to load and for elements to be clickable.

wait = WebDriverWait(self.driver,10)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,".btn-contact.btn.btn-primary"))).click()

Import

from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait 
from selenium.webdriver.support import expected_conditions as EC

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to click on confirmation button using Selenium with Python?

How to click Radio Button using python Selenium

How to click on dynamic button using selenium Python?

How to click on the Search button using Selenium and Python?

How to click the button using selenium python

How to click on the text button using selenium python

How to click this button using Selenium through Python

How to click iframe button on Python using Selenium?

How to click on Search button using Python Selenium

How to click this button with python & selenium

Python - selenium - how to click on the button

How click in Button with Selenium python

How to click certain button using Selenium Python xpath ?

How can I click on a button inside an iframe using Selenium and Python

How to click on a button in python using selenium with aria-label

How to click on the ember.js enabled button using Selenium and Python

How to click a dropdown button within a svg tag using Selenium and Python

How to click on a button by the link text using Selenium and Python

How to click the Continue button on website using selenium in python?

How do I click Alertify dialog button using selenium (Python)

How to Click the "OK" Button within an Alert using Python + Selenium

How do i click a Button inside a Table using Selenium(Python)

How to click a button that has a dynamic ID using selenium Python

How to click button inside html inside #document using selenium in python?

How to click on the See all button using Selenium and Python

How to click on button which is present in a frame using python selenium webdriver

How to click the button with text Send Me a Push using Selenium and Python?

How to click a button inside a frame using python, selenium?

How to click A button on the second window of the browser using Selenium with python