I am unable to resolve this issue by following below answers
Selenium - Python - AttributeError: 'WebDriver' object has no attribute 'find_element_by_name'
I am using python behave with selenium webdriver in updated current version, feature file image attached & below is step file code.
import time
from behave import *
from selenium import webdriver
from selenium.webdriver.common.by import By
from webdriver_manager.chrome import ChromeDriverManager
# access on described PDP
@given('I am on bundle item page named as Nestor Occasional Table Set')
def step_impl(context):
context.driver = webdriver.Chrome(ChromeDriverManager().install())
context.driver.maximize_window() # for maximise windows
time.sleep(2)
context.driver.get(
"Project name removed myself")
time.sleep(2)
@then('Verify the bundle Product sku')
def step_impl(context):
prod_sku = context.driver.find_element(By.XPATH, "//div[@class='product-id' and @aria-label='ASL-T517-0-ROOM']")
# print(prod_sku)
displayed = prod_sku.is_displayed()
print(displayed)
time.sleep(5)
# if displayed is True:
# print('product sku is visible on the screen because displayed value is', displayed)
# else:
# print('product sku is not visible on the screen because displayed value is', displayed)
# time.sleep(0.5)
@then('Verify the bundle Product price')
def step_impl(context):
prod_price = context.driver.find_element(By.XPATH, "//span[@class='price-label' and @aria-label='Final Price']")
# price_view = prod_price.is_displayed()
# print(price_view)
assert prod_price.text == "$540.00"
time.sleep(0.5)
@when('I click on ADD TO CART button to add bundle product in to the cart')
def step_impl(context):
context.driver.find_element(By.XPATH, "//button[@class='button-basic theme-button btn-block']").click()
time.sleep(7)
@then('Verify the added bundle Product in to the cart')
def step_imp(context):
# added_product = context.driver.find_element_by_link_text('Bostwick Shoals Queen Panel Bed')
added_product = context.driver.find_element(By.XPATH, "//div[@id='cart-prodname' and @class='pr-0']")
prod_viewed = added_product.is_displayed()
print(prod_viewed)
time.sleep(1)
@then('Verify the added bundle Product price in to the cart')
def step_impl(context):
# price = context.driver.find_element_by_link_text('$2699.00')
# price = context.driver.find_element_by_xpath("//span[@class='price-label' and @aria-label='Final Price']")
price = context.driver.find_element(By.XPATH, "//div[@class='detail-type text-lg-right col-sm-4']")
# price_view = prod_price.is_displayed()
# print(price_view)
assert price.text == "$540.00 Free Home Delivery*"
assert price.text == "Free Home Delivery*"
time.sleep(1)