I am trying to loop through elements on the main page of Raymour and Flanigan furniture website. I've put all the items in a massive and want to use an action chain method to click through it and verify each one opens up successfully. Since on the website, there is no click option, I am using an action chain. but something is wrong with my code. I think it's the last line
from selenium import webdriver
from behave import given, when, then
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
TOP_LINKS = (By.CSS_SELECTOR, "div.Hdr_MN")
@given('Main Page MyRF')
def open_website(context):
context.driver.get('https://www.raymourflanigan.com/')
@then('User can go through top links and verify page has opened')
def click_thru_top(context):
expected_items = ['Living Rooms', 'Dining Rooms', 'Bedrooms', 'Mattresses', 'Kids', 'Office', 'Decor', 'Rugs', 'Outlet', 'Sale']
top_links = context.driver.find_elements(*TOP_LINKS)
# first_item = (By.CSS_SELECTOR, "a.Hdr_MNCatLink")
for x in range(len(top_links)):
actions = ActionChains(context.driver)
actions.move_to_element(top_links[x]).perform()
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.support.ui import WebDriverWait
driver = webdriver.Chrome()
driver.get("https://www.raymourflanigan.com/")
WebDriverWait(driver, 10).until(
ec.visibility_of_all_elements_located((By.XPATH, "//a[@ng-if='category.URL'][text()='Kids']")))
Top_Links = driver.find_elements_by_xpath("//a[@class='Hdr_MNCatLink ng-binding ng-scope']")
for x in range(0, len(Top_Links)):
WebDriverWait(driver, 10).until(
ec.visibility_of_all_elements_located((By.XPATH, "//a[@ng-if='category.URL'][text()='Kids']")))
Top_Links = driver.find_elements_by_xpath("//a[@class='Hdr_MNCatLink ng-binding ng-scope']")
Top_Links[x].click()