0

I am using "Selenium WebDriver" in Python on Pycharm and I am having problem with element, which is clicking from drop down. What I want is, that when it clicks on "Expiry Month" drop down, it shows all the value and selects "06" and in "Expiry Year" drop down it should select "2021" year, as it is not happening.

import os
import time
import unittest

from selenium import webdriver
from selenium.common.exceptions import *
from selenium.webdriver.common.action_chains import ActionChains
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webelement import WebElement
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait

EmailEntry = "teidi@gmail.com"
password = '12345678'
Name = "Taimoor"


class goodswebDropDownMyWallet ( unittest.TestCase ):

    def setUp(self):
        driverlocation = "/Users/new/Documents/Learning/Drivers/selenium-2.53.1/py/selenium/webdriver/chromedriver"
        os.environ["webdriver.chrome.driver"] = driverlocation
        self.driver = webdriver.Chrome(driverlocation)


    def test_Test1(self):
        driver = self.driver
        url = "https://bizplace.theentertainerme.com/"
        driver.get ( url )
        driver.maximize_window ( )
        driver.implicitly_wait ( 10 )
        self.LoginButton = driver.find_element_by_id ( "signin" )
        self.LoginButton.click ( )

        self.LoginEmail = driver.find_element_by_xpath ( "//*[@id='sign_form-default']//div[1]/input[@type='email']" )
        self.LoginEmail.clear ( )
        self.LoginEmail.click ( )
        self.LoginEmail.send_keys ( EmailEntry )

        self.LoginPassword = driver.find_element_by_xpath (
            "//*[@id='sign_form-default']//div[1]/input[@type='password']" )
        self.LoginPassword.clear ( )
        self.LoginPassword.click ( )
        self.LoginPassword.send_keys ( password )

        self.LoginSubmitButton = driver.find_element_by_xpath ( "//*[@id='sign_form-default']//div[3]/input" )
        self.LoginSubmitButton.click ( )
        time.sleep ( 5 )

        IncorrectEPMessage = driver.find_element_by_xpath ( "//*[@id='sign_form-default']/p[2]" )
        if IncorrectEPMessage.is_displayed ( ):
            print ( "Either Email or Password is incorrect" )
        else:
            print ( "Everything is fine" )

        TitleDropdown = driver.find_element_by_xpath ( "//*[@id='user']/li[2]//a" )

        def titleDropDown():

            newactions = ActionChains ( driver )
            newactions.move_to_element ( TitleDropdown ).perform ( )
            time.sleep ( 2 )
            MyProfile = driver.find_element_by_link_text ( "Wallet" )
            newactions.move_to_element ( MyProfile ).perform ( )
            time.sleep ( 3 )
            newactions.move_to_element ( MyProfile ).click ( ).perform ( )
            time.sleep ( 5 )
            Wait = WebDriverWait ( driver, 10 )

        titleDropDown()
        Wait = WebDriverWait(driver, 10, poll_frequency=1,
                                          ignored_exceptions=[NoSuchElementException, ElementNotVisibleException] )
        Wait.until(EC.url_changes((By.TAG_NAME, "h2")))

        time.sleep ( 3 )
        NameofHeading = driver.find_element_by_tag_name ( "h2" )
        print ( NameofHeading.text )
        time.sleep ( 3 )
        AddCreditcard = driver.find_element_by_xpath ( "//*[@id='add_card']//a" )
        AddCreditcard.click ( )

        time.sleep(5)
        ChangingCardHeader = driver.find_element_by_xpath ( "//*[@id='wrapper']/div/div/div/div/div/div/div/div[1]/p" )
        print ( ChangingCardHeader.text )

        CreditCardNumber = driver.find_element_by_id("cardpayment-card_number")
        CreditCardNumber.send_keys('4543474002249996')

        newactions2 = ActionChains (driver)
        ExpiryMonth = driver.find_element_by_xpath("//*[@id='wallet_mobile']/fieldset/div[2]/div[1]/div/div/div/span")
        ExpiryMonth.click()
        Month = driver.find_element_by_xpath("/html/body/div[17]/div/span/span/ul/li[7]/span")
        driver.execute_script("return arguments[0].scrollIntoView();", Month)
        time.sleep(5)
        Month.click()


        ExpiryYear = driver.find_element_by_xpath("//*[@id='wallet_mobile']/fieldset/div[2]/div[2]/div/div/div/span")
        ExpiryYear.click()
        Year = driver.find_element_by_xpath("/html/body/div[17]/div/span/span/ul/li[10]/span")
        driver.execute_script ( "return arguments[0].scrollIntoView();", Year)
        time.sleep(3)
        Year.click()

        CVVEntry = driver.find_element_by_id("cardpayment-cvn")
        CVVEntry.click()
        CVVEntry.send_keys('956')

        CardHolderName = driver.find_element_by_id("cardpayment-card_name")
        CardHolderName.click()
        CardHolderName.send_keys(Name)


    def tearDown(self):
        print ( "Wallet is opening" )


if __name__ == "__main__":
    unittest.main ( )

After Running the code, I am facing the following error:

Error
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/unittest/case.py", line 58, in testPartExecutor
    yield
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/unittest/case.py", line 600, in run
    testMethod()
  File "/Users/new/PycharmProjects/Selenium/DropDownWallet.py", line 100, in test_Test1
    ExpiryYear.click()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 80, in click
    self._execute(Command.CLICK_ELEMENT)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webelement.py", line 501, in _execute
    return self._parent.execute(command, params)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/webdriver.py", line 308, in execute
    self.error_handler.check_response(response)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/selenium/webdriver/remote/errorhandler.py", line 194, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: unknown error: Element <span class="jcf-select jcf-unselectable jcf-select-form-control">...</span> is not clickable at point (697, 16). Other element would receive the click: <div class="holder">...</div>
  (Session info: chrome=62.0.3202.94)
  (Driver info: chromedriver=2.33.506106 (8a06c39c4582fbfbab6966dbb1c38a9173bfb1a2),platform=Mac OS X 10.13.0 x86_64)

Can someone please Help me on this?

TeSter
  • 119
  • 1
  • 11
  • try once with firefox selenium driver – imox Dec 11 '17 at 08:56
  • You shouldn't need all those sleeps. Selenium has in built implicit and explicit waits for that.You might need to [hover over the element](https://stackoverflow.com/questions/17293914/how-to-perform-mouseover-function-in-selenium-webdriver-using-java) first before clicking. – lloyd Dec 11 '17 at 09:00
  • Possible duplicate of [Selenium Web Driver & Java. Element is not clickable at point (36, 72). Other element would receive the click:](https://stackoverflow.com/questions/44912203/selenium-web-driver-java-element-is-not-clickable-at-point-36-72-other-el) – undetected Selenium Dec 11 '17 at 09:41
  • @lloyd first its not about sleep, I will get rid of them after running these programs succesfully, and secondly its not a hover over the element components. its just a drop down. – TeSter Dec 11 '17 at 14:24

2 Answers2

0

You can try using selenium's execute_script.

Change

ExpiryYear.click()

to

driver.execute_script('arguments[0].click();', ExpiryYear)
imox
  • 1,544
  • 12
  • 12
  • I have tried both. As ExpiryYear.click() will just open dropdown.. and execute_script have already been used, both are in vain :( – TeSter Dec 11 '17 at 14:22
0

I have the same issues when error says: (button)is not clickable at point (697, 16). Other element would receive the click:(overlay) I tried following but failed:

  1. driver.execute_script('arguments[0].click()', submit)
  2. use ActionChain to move to that position and perform click
  3. Sleep until it disappears (the overlay last forever)

And I tried to use DevTools -> Inspect the element -> right click -> Copy XPath -> paste in my find_element(By.XPATH) something like:

driver.find_element(By.XPATH, "//[@id='LoginModal']/div/div/div[" "2]/div[2]/div[2]/div/div/div/div[3]/form/div[3]/div[1]/button").click().

It finally works!

And here is my old XPath: driver.find_element(By.XPATH, "//button[""@type='submit']").click()

It seems that the copied XPATH just works better in my case.

Weili Yin
  • 21
  • 4