Java: Selenium Typing in Incorrect Input Field

I am currently facing a challenge with setting the "Buy It Now" price on an eBay listing that has been advanced.

Here is the URL:

The code I am using includes:

    String BINCSS = "#binPrice";
    String BINXPath = ".//*[@id='binPrice']";

I want to set the "Buy It Now" price as a fixed price instead of an Auction price. My method involves first clicking on the "Fixed Price" tab and then inputting the price using the XPath / CSS mentioned previously.

This process works, but it inputs the price into the wrong field - specifically, it places the price in the "Buy It Now" field under "Auction", rather than in the desired "Fixed Price" tab.

Can someone provide guidance on how to correctly enter the fixed price in the "Buy It Now" text box?

Thank you.

Answer №1

Both the Fixed Price tab and the Auction tab share the same locator address. This results in the Buy It price being visible in both tabs.

To navigate to the Buy It Now price specifically in the Fixed Price tab, use the absolute xpath instead of the relative xpath .//*[@id='binPrice'].

Answer №2

After some careful investigation, I managed to locate the "Fixed Price" tab through a specific link and initiated a click action before entering values in the "Buy It Now" field.

driver.findElement(By.xpath(".//*[@id='userid']")).sendKeys("input email");
        driver.findElement(By.xpath(".//*[@id='pass']")).sendKeys("type password");
        driver.findElement(By.xpath(".//*[@id='sgnBt']")).click();
        driver.manage().window().maximize();
        JavascriptExecutor jse = (JavascriptExecutor)driver;
        jse.executeScript("window.scrollBy(0,1650)", "");
        driver.findElement(By.linkText("Fixed price")).click();
        Thread.sleep(5000);
        driver.findElement(By.xpath(".//*@id='binPrice']")).sendKeys("500");

I'm optimistic that this solution will also yield positive results for you!!

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

make the text in em font size larger

Incorporating HTML dynamically into a page using JavaScript is shown in the example below. _strInnerHtml += "<em>" + value.cate_name + " | " + value.city_name + "</em>"; _strInnerHtml += "<a href='#' class='activi ...

Printing from a lengthy React DOM using window.print only generates a single page

My React component is capable of rendering markdown and can span multiple pages. Everything looks great when the component is displayed in the browser - scrolling works perfectly. However, whenever I try to print the page using window.print or ctrl + P, ...

Can anyone provide guidance on displaying a JS alert every time a tab in the slider is opened?

Utilizing the liquidslider script on my website, I have created a slider with the following HTML code: <div class="liquid-slider" id="slider-id"> <div> <h2 class="title">Slide 1</h2> // Content goes here ...

Issue with Bootstrap 5 Carousel not transitioning between slides

I am trying to add a carousel to my webpage, but it seems like it's not sliding and only displaying the first image. I've double-checked my code and everything else from Bootstrap works fine. Here's the snippet of code I'm using: < ...

Dynamic resizing of elements/images using jQuery to maintain proportions

My goal is to create a design where images resize proportionally with their containing elements. The challenge I am facing is achieving the proportional resizing of each image container's height as its width changes upon window resize. Currently, the ...

Error: java.lang.ClassCastException is occurring because the Google App Engine datastore Text object cannot be converted to a regular String object

I am currently working on downloading an Excel file to my local computer from a web application that is deployed on Google App Engine. The data I am retrieving from the Entity does not contain any Text fields, all of them are String fields. However, when I ...

Ensure that images in a browser maintain their proportions without distortion on all device screens and orientations by setting their height and width to match the

I'm working on a slideshow component in React and I want the images to dynamically adjust to fit any device screen size and orientation. The goal is for the image to resize proportionally until it reaches either the top and bottom edges or left and ri ...

Concealed image lurking beneath navigation bar

My navbar displays an image below it, but the top part of the image is cut off. The desired outcome is for the image to start at the bottom of the navbar to prevent any cropping issues. This becomes more noticeable as the screen size decreases. I attempted ...

Navigating to the final comment on a YouTube video: A step-by-step guide

Currently, I am exploring the realm of web scraping with selenium and facing a task that involves extracting all comments from a YouTube video. To achieve this, I need to scroll down to reach the last comment. Despite my efforts, the code I've impleme ...

Using the Genymotion emulator in conjunction with Selenium can greatly enhance

Is it possible to combine the Genymotion emulator with Selenium for testing Android app functionality? Can we use Genymotion emulator instead of a physical device for running Selenium tests on an Android app? ...

Adjusting page layout following window dimension changes

Every time I work on developing HTML pages, I encounter issues with window resizing. The alignment of the page gets disrupted and elements end up overlapping each other. I want my page to maintain its layout when resized, with scrollbars appearing instea ...

Tips for designing a CSS Grid that features a maximum width for the main content and a minimum width for the sidebar

I'm attempting to design a two-column CSS grid with a main content area that has a maximum width of 800px and a sidebar that has a minimum width of 200px: https://codepen.io/dash/pen/gOmXqGr The grid needs to be responsive: The yellow sidebar should ...

Tips for avoiding a split in the bootstrap navbar when collapsed

I've been searching for hours and still can't figure it out, so I'm really hoping someone can help me solve this before I embarrass myself. My goal is to create a navigation bar similar to the one on steamdb, where the search box remains vi ...

Error occurred during download or resource does not meet image format requirements

Encountering an issue when attempting to utilize the icon specified in the Manifest: http://localhost:3000/logo192.png (Download error or invalid image resource) from the console? import React from 'react'; import Logo from '../Images/logo1 ...

Creating dynamic div shapes in HTML is a fun and creative way

Is it possible to create a div with a unique shape? I know that by default, divs are rectangular and you can achieve some shapes using the border-radius property, but what I really want is a semi-leaf shaped element. Something like this: The image might n ...

What could be the reason behind my jQuery UI buttons suddenly appearing oversized and lackluster?

Previously, I utilized the jQuery UI to enhance button appearance. However, with this code snippet: else if (ui.newTab.index() == 3) { $('#MediaContent').load('Content/TwainMedia.html'); $('#MediaContent').css('b ...

Achieving priority for style.php over style.css

Having trouble with theme options overriding default CSS settings in style.css. Here's what I have in my header.php: <link rel='stylesheet' type='text/css' media='all' href="<?php bloginfo( 'stylesheet_url&apo ...

Troubleshooting the Issue with Jquery Menu and Mouse Pointer

Recently, I've been attempting to modify the cursor behavior on a navigation menu that I stumbled upon at HTML Drive's JQuery Menu. I experimented with CSS and jQuery. In my JQuery attempt, I utilized... $("body").hover(function() { $(this).cs ...

Automatically removing a record in Java either after a set time period has elapsed or when a specific time threshold is reached

I'm currently working on a Java web application where users can share their statuses and view others' as well, creating a social networking atmosphere. Each status has a limited display period, after which it is removed from the database. Whe ...

Rearranging Twitter Bootstrap Grid Columns

Is it possible to rearrange columns in Bootstrap without using col-sm-pull-12/col-sm-push-12? I'm struggling to achieve the desired layout. Are there any alternative methods to accomplish this task? Check out this JSFiddle for reference. <div cla ...