Is there a way to confirm the functionality of the button for May 1st, 2019?

Currently using Eclipse(java) along with Selenium, encountering issues validating a button click event on the May 1st, 2019 date entry.

The following methods have been attempted:

driver.findElement(By.className("gws-travel-calendar__day-label")).click(); 

as well as:

driver.findElement(By.xpath("//div[contains(@className,'gws-travel-calendar__day-label')][contains(input, '1')]")).click();

An illustration of the calendar and the related div can be viewed in this image: https://i.stack.imgur.com/MlcxN.png

Answer №1

  1. driver.findElement(By.className("gws-travel-calendar__day-label")).click();

    The specified locator is not unique as there are 365 nodes with the same class name. Selenium may get confused on where to click.

  2. driver.findElement(By.xpath("//div[contains(@className,'gws-travel-calendar__day-label')][contains(input, '1')]")).click();

    The provided xpath is incorrect. Only one attribute of a tag can be used at a time like @class or @name. The contains method has a different syntax than what you have used. It should be used in the following ways:

    //div[contains(text(),"text to verify")]

    //div[contains(@name,"value of name attribute")]

    //div[contains(@class,"value of class attribute")]

  3. You can find the element using this xpath:

    driver.findElement(By.xpath("//calendar-day[@data-day="2019-05-01"]")).click();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Error caused by @Autowired with NullPointerException in the Main class

My plan is to create a custom @Service that provides me with a Selenium WebDriver using dependency injection. Check out the code snippet below: import java.io.File; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.Chr ...

When I tried running a basic AJAX JQuery code snippet, it unexpectedly threw a 500 internal

Hey there! I'm currently working on a Spring MVC project and encountering an error when I click the button in my form. 500 (Internal Server Error) jquery.min.js:6 x.ajaxTransport.x.support.cors.e.crossDomain.send j ...

Recent ExtentReports Maven dependency for Selenium available now

I included the following in my POM file. <dependency> <groupId>com.aventstack</groupId> <artifactId>extentreports</artifactId> <version>3.0.5</version> </dependency> Unfortunately, it seems ...

I'm having trouble accessing a button on a website using Python's Selenium

There seems to be an issue with the code below import os import time from selenium import webdriver driver = webdriver.Firefox() driver.get("http://x.x.x.x/html/load.jsp") elm1 = driver.find_element_by_link_text("load") time.sleep(10) elm1.click() time.sl ...

Stopping the loading of a browser page in Selenium WebDriver is a crucial step to ensure

Currently, I am utilizing the Selenium WebDriver in C# and experiencing an unusual issue. During my automation process, I stumbled upon a situation where the page keeps loading indefinitely even after the DOM content has already loaded. This prevents me fr ...

Having difficulty transitioning to a frame with the web driver

I am having trouble switching to the frame because it lacks a name or an ID. Input field values need to be entered. Webpage: Frame: <!DOCTYPE html> <html class=" js flexbox canvas canvastext webgl no-touch geolocation postmessage no-websql ...

Tips for managing popup browsers in Robot Framework

When using Robot Framework, I encountered a challenge with handling pop up browsers to allow access to the camera. The issue arises when trying to press Enter on the selected 'Allow' button after navigating there via the TAB key. Despite various ...

Nested Elements in Java JSON with Jackson

I have a JSON string that contains nested values. It looks something like this: "[{"listed_count":1720,"status":{"retweet_count":78}}]" I am interested in extracting the value of retweet_count. Currently, I am using Jackson to work with this data. The ...

Comparing Java strings using the getText() method

I am working with two strings in my code: String currentDoc= driver.findElement(By.cssSelector(".active .ng-scope:nth-child(2)")).getText(); This is the outcome of the first string: First Name Last Name Remove Worker details Goran Dxxxxxc David ...

Is it possible to interact with hidden elements in Selenium using Java WebDriver without the need for the javascript executor?

Is there a way to interact with hidden or non-visible elements using the Java Selenium Webdriver without relying on the JavaScript executor to simulate clicks? I need to run tests on a browser that has JavaScript disabled, so the traditional jse method w ...

Having trouble accessing org.openqa.selenium.webdriver with selenium?

After installing Java 13.0 and the latest version of Selenium, I encountered an error stating "org.openqa.selenium.webdriver is not accessible", which prompted me to change the compliance level from 13 to 1.8. Below is the error message that I am currentl ...

Tips for launching a hyperlink in a new tab using Python and Selenium

When browsing a website, I am having trouble opening links in a new tab using Selenium with Python. Despite trying various solutions suggested here, the new tabs simply refuse to open as intended. (I've attempted different methods, but none seem to wo ...

Converting a List of Strings to a JSON String

Is there a way to transform a List into a Json String? I've successfully done it in the opposite direction, but struggling with this method. Addtionally, I'm unsure how to define the specific key names. ...

Struggling with eclipse, cucumber, and selenium throwing a java.lang.ClassNotFoundException for gherkin.lexer.Encoding?

I'm new to using cucumber and I came across an example that seems to be working fine for the most part, but I keep encountering the following exception: java.lang.NoClassDefFoundError: gherkin/lexer/Encoding at cucumber.runtime.FeatureBuilder.read(Fe ...

Setting up preferences for Chrome in Selenium using Python is a useful skill to have

Setting preferences for Firefox is simple with the code snippet provided below. set_preference = profile.set_preference set_preference("network.http.response.timeout", 30) set_preference("media.autoplay.enabled", False) set_preference("browser.cache.memor ...

Utilizing Selenium Grid in Conjunction with Page Object Model Page Factory

I am looking to optimize my browser initialization process for testing on multiple browsers using the Page Object Model Page Factory. Currently, I have the following setup in my Base Class: // initialize driver/browser public void initDriver() throws Ma ...

Unable to convert the text string into my desired object

The JSON string I received has been validated by jsonlint. A decodedCookie string is created using URLDecoder to decode the value of myCookie in UTF-8 format, and then Gson is used to parse it. Here is what the string looks like: { "urlAW": "http://w ...

What could be causing Selenium to point to the wrong root directory in this particular CircleCI 2.0 build?

I'm currently in the process of setting up a Rails application for testing on CircleCI 2.0, which was previously functioning well on v1.0. I have created a configuration file with the following Docker images (this is my first experience with Docker, ...

Tips on extending the duration of Selenium sleep until the song finishes playing

Is there a way to extend the sleep time until my song has finished playing? I am currently developing a voice assistant. def play(self, query): self.query = query self.driver.get(url="https://www.youtube.com/results?search_query=" ...

Having trouble retrieving an excel sheet using a User-Defined Function (UDF) in Selenium WebDriver

I am currently learning about User Defined Functions (UDF) within a hybrid framework. I have developed an "ExcelUtils" class where I wrote code to read and write from an excel sheet. Additionally, I created a "Utils" class in which I encountered an issue w ...