2

enter image description hereI want to click the button called "바카라 멀티플레이" which locates center of the site. I switched into iframe, however it seems to be not detecting the button. How can I?

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions
import sys
import asyncio

"""
    Chromedriver Options / Driver setting
"""
options = webdriver.ChromeOptions()
#ptions.add_argument('headless')
options.add_argument('window-size=1920,1080')
options.add_argument("disable-gpu")

driver = webdriver.Chrome(executable_path='C:/chromedriver/chromedriver.exe', chrome_options=options)

driver.get('https://ggl-maxim.com/')

driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[1]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[2]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/button[1]').click()

time.sleep(2)
driver.get('https://ggl-maxim.com/api/popup/popup_menu.asp?mobile=0&lobby=EVOLUTION')
wait = WebDriverWait(driver, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it("gameIframe"))
driver.find_element_by_class_name(".wrapper--1zUtU").click()
wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".svg--1nrnH")))
2
  • Try using this xpath driver.find_element_by_xpath("//div[@class='wrapper--1zUtU']") for the button 바카라 멀티플레이 Commented May 26, 2021 at 3:26
  • Check another answer, it should resolve the question you asked in comments. Next time try to formulate the question correctly initially. Commented May 26, 2021 at 5:14

3 Answers 3

1

This .svg--1nrnH does not represent the button you wanna click. Plus that is a svg element you cannot use just the that css selector to locate the element.

Code :

driver = webdriver.Chrome("C:\\Users\\***\\**\\Desktop\\Selenium+Python\\chromedriver.exe")
driver.maximize_window()
wait = WebDriverWait(driver, 30)
driver.get('https://ggl-maxim.com/')

driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[1]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/input[2]').send_keys('tnrud3080')
driver.find_element_by_xpath('//*[@id="body"]/div/div[2]/div/div[2]/fieldset/button[1]').click()
sleep(5)
driver.get('https://ggl-maxim.com/api/popup/popup_menu.asp?mobile=0&lobby=EVOLUTION')
wait.until(EC.frame_to_be_available_and_switch_to_it((By.ID,"gameIframe")))
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, ".wrapper--1zUtU")))
sleep(5)
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".wrapper--1zUtU button"))).click()
sleep(5)
print("Operation successful")

O/P :

enter image description here

Sign up to request clarification or add additional context in comments.

16 Comments

@famas kim : Check out this code and let me if it works for you
It doens't click the button. I think it need to wait for the delay also.
I will post it with picture
@famaskim Show on a screenshot which elements you are waiting for. As I see it, you do not need to wait for them because they are already loaded...
yes he wants to grap baccarat data, but I can locate it since I don't understand that language
|
0

For the login action use the below xpaths. This way your code will look neat.

driver.get('https://ggl-maxim.com/')

driver.find_element_by_xpath("//input[@placeholder='아이디']").send_keys('tnrud3080')
driver.find_element_by_xpath("//input[@placeholder='비밀번호']").send_keys('tnrud3080')
driver.find_element_by_xpath("//button[@class='btn_apply']").click()

For the click of button 바카라 멀티플레이, try using the below xpath and see if it works:

driver.find_element_by_xpath("//div[@class='wrapper--1zUtU']").click()

6 Comments

How can I wait for "svg--1nrnH" after clicking the button?
Because the site is loading to show multipaly chart
You can add WebDriverWait with expected_conditions
wait = WebDriverWait(driver, 500) wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, ".wrapper--1zUtU button"))
@famaskim What is ".svg--1nrnH and why do you need to wait for it if it's already loaded.
|
0

After you click that button to get the games list you need to switch to another iframe. There are two iframes with a very similar names, so I used selector which indicates that iframe name starts with https://evo.kplaycasino.com/frontend/evo/r2/#category"].

from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.common import exceptions
import sys
import asyncio

"""
    Chromedriver Options / Driver setting
"""
options = webdriver.ChromeOptions()
#ptions.add_argument('headless')
options.add_argument('window-size=1920,1080')
options.add_argument("disable-gpu")

driver = webdriver.Chrome(executable_path='/snap/bin/chromium.chromedriver', chrome_options=options)

driver.get('https://ggl-maxim.com/')

driver.find_element_by_xpath("//input[@type='text']").send_keys('tnrud3080')
driver.find_element_by_xpath("//input[@type='password']").send_keys('tnrud3080')
driver.find_element_by_css_selector('.btn_apply').click()

time.sleep(2)
driver.get('https://ggl-maxim.com/api/popup/popup_menu.asp?mobile=0&lobby=EVOLUTION')
wait = WebDriverWait(driver, 20)
wait.until(EC.frame_to_be_available_and_switch_to_it("gameIframe"))
wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".svg--1nrnH")))
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, ".wrapper--1zUtU button>span")))
driver.find_element_by_css_selector(".wrapper--1zUtU button").click()
wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, 'iframe[src^="https://evo.kplaycasino.com/frontend/evo/r2/#category"]')))
iframe2 = driver.find_element_by_css_selector('iframe[src^="https://evo.kplaycasino.com/frontend/evo/r2/#category"]')
driver.switch_to.frame(iframe2)
wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".svg--1nrnH")))

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.