Using Selenium with Firefox to interact with span elements

Having trouble selecting an element by linkText within a span tag? It works in Chrome, but not in Firefox. The code I'm using is:

login.wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Kassa"))).click();
Other elements without the span tag work fine. What's the best way to reach this element?

<nav class="site-navbar navbar navbar-inverse navbar-fixed-top bg-teal-600" role="navigation">
    <div class="container-fluid">
        <div class="navbar-header">
                <div class="navbar-brand site-gridmenu-toggle" data-toggle="gridmenu">
                    <span class="navbar-brand-text">whatever</span>
                </div>
            <button type="button" class="navbar-toggle hamburger hamburger-close collapsed" data-target="#site-navbar-collapse" data-toggle="collapse">
                <i class="hamburger-bar" aria-hidden="true"></i>
            </button>

            <button type="button" class="navbar-avatar navbar-toggle padding-horizontal-0" data-toggle="dropdown" href="#" aria-expanded="false" data-animation="scale-up" role="button">
                <span class="avatar avatar-online" style="top: -3px">
                    <img src="https://whatever.png" alt="...">                  <i></i>
                </span>
            </button>

                         <a type="button" href="https://whatever" class="navbar-toggle padding-top-15 padding-horizontal-0">
                <span class="btn btn-warning"> Kassa </span>
            </a>

Code snippet:


System.setProperty("webdriver.gecko.driver","C:\\Utility\\BrowserDrivers\\geckodriver.exe");
driver = new FirefoxDriver();
wait = new WebDriverWait(driver, 10);
driver.manage().window().maximize();

Trying to find the element on the webpage:

login.wait.until(ExpectedConditions.elementToBeClickable(By.linkText("Kassa"))).click();

Image of the navigation bar nav. bar

Answer №1

While it's typically expected that code working in Chrome will also work in Firefox, sometimes this isn't the case. If you encounter issues, consider locating the element using the following approach:

UPDATED METHOD:

WebElement navElement = driver.findElement(By.cssSelector("div.container-fluid a>span.btn.btn-warning"));

Actions action = new Actions(driver);
action.moveToElement(navElement).click().build().perform();

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

finding textarea element in selenium for beginners

I'm having trouble finding the textarea field using Selenium. So far, I've attempted the following: driver.findElement(By.xpath("//textarea[@id='inviteColleaguesArea']")).sendKeys("[email protected]"); WebElement element=driver.findElem ...

Ways to access the Page Source of a subsequent page

My current goal is to convert the driver into html for use with beautiful soup. However, I am encountering an issue where the output from the prettifier (the one in the driver) shows the HTML of the login page instead of the page that should come after it ...

Using Python to interact with Selenium to click buttons that share the same name and ID

I am in need of an application that can click on the correct button when a specific option is available. I have identified a value that will change when the other option is not present. <form name="uniforma_NE" id="uniforma_NE" .=&qu ...

Handling errors in Python selenium automation

My Python Selenium script involves running through a loop as shown below... for i, refcode in enumerate(refcode_list): try: source_checkrefcode() except TimeoutException: pass csvWriter.writerow([refcode, 'error' ...

Managing print dialog box in selenium automation

Within my application, there is a button designed for printing. Upon clicking this print button, a new window containing cancel and print options appears. My goal is to interact with the cancel button within the print window. Despite understanding that h ...

Dealing with Chrome pop ups in Java Selenium with the ChromeDriver: Tips to deny or block them

I'm encountering an issue where every time my program attempts to visit a specific website, Chrome displays a pop-up asking for permission to continue in an app that I do not wish to install. I want to either deny this permission or completely block i ...

elementToBeClickable is not supported by webdriverio

I am having some trouble with the 'waitForEnabled' function as it does not seem to behave like Webdriver's elementToBeClickable. Is there anyone who can provide some guidance on how to use this API effectively? ...

Encountered an Error with My Protractor Script - Object Expected

Currently, I am in the process of learning automation testing for an AngularJS application. However, I have encountered an "object expected" error on line 4, which is pointing to the first line of my script. describe("Homepage", function() { it("Navig ...

Compiling a directory of video URLs - hindered by email encryption

I am relatively new to Python and coding, so please bear with me as I explain my current project. Basically, what I'm trying to accomplish is creating a script that opens my monthly fire department training page, navigates to the video section where d ...

Is there a way to retrieve the current version of selenium, selenium server, or selenium webdriver through programming methods?

Currently, I am conducting automated tests across different environments and it is crucial for me to understand the runtime scenario accurately. I have noticed discrepancies in the performance of identical Ruby scripts and I want to be able to gather as m ...

How can we use Cypress to check if we are at the final slide in the presentation?

I am facing a challenge with multiple slideshow files that contain varying numbers of slides. Some have 10 slides, while others have 80 slides. My goal is to test every slide by using the forward and backward arrow buttons for navigation. Currently, I am c ...

What is the method for fetching text with neither a node nor attribute using xpath in Selenium?

I am currently attempting to extract specific text from an HTML document using xpath. The structure of the HTML is shown below: The desired "target text" that I want to retrieve is located within a p node. However, this "target text" does not have any s ...

Configure Serenity's Capability to overlook any UnhandledAlertException

Just dipping my toes into the world of Cucumber and Serenity. I'm looking for a way to handle the UnhandledAlertException. This is how you can configure Chrome capabilities in Selenium: capabilities.setCapability(CapabilityType.UNEXPECTED_ALERT_BEH ...

Issue with clicking the OK button in Selenium WebDriver using Java due to the presence of a span tag within the button tag

This is the HTML code snippet that I am working with: <div id="sieb-ui-popup-mvg-selected" class="AppletStylePopup"> <form onsubmit="return false;" action="/ecom_enu/start.swe" method="post" name="SWEForm4_0"> <div class="siebui ...

Viewport height-responsive image not functioning as expected in Firefox browser

Is there a way to set an image to the 100% height of the browser window, with a small padding at the bottom, and have it centered on the page? I created an example in codepen that works well in Chrome and Safari, but not in Firefox. In Firefox, the image ...

Error message on Cypress with TypeScript: No test specification files detected

Encountering the error "Unable to run because no spec files were found, even though there is a .ts spec file in Cypress. Execute the command below in the terminal: npx cypress run --spec="./cypress/integration/specs/Test1.spec.ts". Attempted to run the t ...

Using Selenium WebDriver in Java to click on the Facebook sharing button for the specific post I am interested in

I'm struggling to locate and click the share button on a Facebook post. Let's say I have 4 posts displayed on my Facebook page, and I want to share one of them by clicking on 'Share' and then selecting 'share...' from a small ...

The Protractor Custom Locator is experiencing difficulty in finding the element

For our project, the automation team is incorporating a custom attribute called 'lid' to elements where unique identification is challenging. A new custom locator method has been developed to find elements using the 'lid' attribute: ...

Getting started with Jmeter Web Driver: launching WDS within a pre-existing Chrome session

To validate a web request, I must launch Jmeter and link it to an existing Google Chrome session. The necessary components have been included in Jmeter: jp@gc - Chrome Driver Config jp@gc - WebDriver Sampler However, I am stuck on finding the correct code ...

What is the best way to align these div elements within a table cell?

I am encountering an issue with the placement of elements. What I am striving for is something like this: https://i.stack.imgur.com/VSFXE.png where a div with several other divs inside is positioned at the top of the td, and another div is at the bottom o ...