I am trying to get some data from this website link
This is my code:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
import time
driver = webdriver.Edge("C:/Users/Hamita/Documents/msedgedriver.exe")
driver.get("https://www.bountou1x2.com/sport.jsp?ispt=null")
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//*[#id=\"iframe-alto-sinistra\"]")))
WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH,"//*[#id=\"left-menu-container\"]/div[1]/div[1]"))).click()
But it's giving me this error:
selenium.common.exceptions.TimeoutException
The button i want to click is to select Today, it's located in the left side
Help is appreciated, thanks to all of you
The <iframe> you are trying to switch to is located by the following ID receiver
So you should use:
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.ID,"receiver")))
instead of
WebDriverWait(driver,10).until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"//*[#id=\"iframe-alto-sinistra\"]")))
Related
I am new to python and selenium. Trying to automate download of files from the dropdown menu on the below link for the first time. The code gets stuck after page loads i.e the drop down does not work and gives me an error. Sorry if my code looks clunky. Any help is appreciated.
Thanks
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.select import Select
import time
s=Service("C:\\python\\chromedriver.exe")
driver = webdriver.Chrome(service=s)
driver.maximize_window()
driver.get('http://www.amfiindia.com/research-information/aum-data/classified-average-aum')
#monthname=driver.find_element(By.XPATH,"//*[#id='AaumDate']")
monthdd=Select(monthname)
monthdd.select_by_value('01-Jan-22')
time.sleep(3)
typename=driver.find_element(By.XPATH,"//*[#id='AumType']")
typedd=Select(typename)
typedd.select_by_visible_text('Scheme category wise')
time.sleep(3)
mfname=driver.find_element(By.XPATH,"//*[#id='AumMFName']")
mfdd=Select(mfname)
mfdd.select_by_visible_text('All')
time.sleep(3)
driver.find_element("class name","sprite-inter go-btn").click()
wait=WebDriverWait(driver,20)
driver.get('http://www.amfiindia.com/research-information/aum-data/classified-average-aum')
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR,"#divAumPeriod > span > a > span.ui-button-text"))).click()
wait.until(EC.element_to_be_clickable((By.XPATH,"//*[#class='ui-menu-item']/a[.='January - 2022']"))).click()
Most of these tags open like so and have another list with them that's not using the select tag.
Imports:
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
I am using Selenium with Python on a webpage with JavaScript. The script runs until a pop=up asks for a click either to agree or seek More Options labels appear. The HTML for the pop-up disappears if an option is manually clicked. Would appreciate some guidance on how to click "Agree" automatically.
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
driver = webdriver.Chrome(executable_path='C:/A38/chromedriver_win32/chromedriver.exe')
driver.implicitly_wait(30)
driver.maximize_window()
# Navigate to the application home page
driver.get("https://www.sportinglife.com/racing/results/2020-11-23")
To click on the button with text AGREE. First induce waits for page load and then wait for the element to be clickable.
driver.get('https://www.sportinglife.com/racing/results/2020-11-23')
wait=WebDriverWait(driver, 10)
wait.until(EC.element_to_be_clickable((By.XPATH, "//button[text()='AGREE']"))).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
This will do the trick:
driver.find_element_by_xpath('//*[#id="qc-cmp2-ui"]/div[2]/div/button[2]').click()
I am getting error (element not interactable) when I am trying to send keys into the input field. When I am trying to only click the input filed I am able to do but when giving text it is showing error I have so many things to solve this but I am getting this error only.
My code:
from selenium import webdriver
Driver=webdriver.Chrome()
Driver=get('https://YouTube.com')
Box=Driver.find_element_by_xpath('//*[#id="search-input"]')
Box.send_keys('music') ```
The searchbar is input(id=search) in div class(search-input). Try this;
from selenium import webdriver
Driver=webdriver.Chrome()
Driver.get('https://YouTube.com')
Box=Driver.find_element_by_id('search-input').find_element_by_id('search')
Box.send_keys('music')
To send elements to the search box. First induce a wait for the element to be clickable due to page load.
Box=WebDriverWait(Driver, 10).until(EC.element_to_be_clickable((By.CSS_SELECTOR, "input#search")))
Box.send_keys('music')
Import
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
Try with that:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
Driver=webdriver.Chrome()
Driver=get('https://YouTube.com')
Box=Driver.find_element_by_xpath('/html/body/ytd-app/div/div/ytd-masthead/div[3]/div[2]/ytd-searchbox/form/div/div[1]/input')
Box.send_keys('music')
I was trying to access the search bar of this website: https://www.kissanime.ru
using selenium. I tried it using xpath, class, css_selector but every time this error pops up in the terminal.
selenium.common.exceptions.NoSuchElementException: Message: Unable to
locate element: //*[#id="keyword"]
My approach to the problem was :
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
driver=webdriver.Firefox()
driver.get("https://kissanime.ru/")
driver.maximize_window()
search=driver.find_element_by_xpath('//*[#id="keyword"]')
search.send_keys("boruto")
search.send_keys(Keys.RETURN)
Try adding some wait
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions
search = WebDriverWait(driver, 10).until(expected_conditions.visibility_of_element_located((By.ID, "keyword")))
Add wait to avoid race condition
driver.implicitly_wait(20)
I am attempting to make a auto script bot that find a specific item and adds the item to the users cart and so forth. Right now I am caught up getting python to select the size from the dropdown menu.
I also went with the WebDriverWait function because it was giving me a element not found error , so i assumed it the 'size' element had not loaded yet.
Python is also throwing me this error
"TypeError: 'str' object is not callable"
Below is also a picture of the html code I am referencing to pull the information from. Also will appreciate any advice on better executions.
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
# Open chrome web browswer and directs to supreme.com
browser = webdriver.Chrome()
browser.get('http://www.supremenewyork.com/shop/all')
#Find specific item
browser.find_element_by_xpath('//*
[#id="container"]/article[14]/div/a/img').click()
#Wait for element to load
pause = WebDriverWait(browser,10).until(
EC.visibility_of_any_elements_located(By.ID('size'))
)
# Select size
Select = Select(browser.find_element_by_id('size'))
Select.select_by_visible_text("Large")
Try below code.
from selenium import webdriver
from selenium.webdriver.support.select import Select
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
browser = webdriver.Chrome()
browser.get('http://www.supremenewyork.com/shop/all')
browser.find_element_by_xpath('//*[#id="container"]/article[12]/div/a/img').click()
WebDriverWait(browser,10).until(EC.visibility_of_any_elements_located((By.ID,'size')))
select = Select(browser.find_element_by_id('size'))
select.select_by_visible_text("Medium")