1
This is my docker file # Base image with Maven and JDK FROM maven:3.8.4-openjdk-11 # Set the working directory in the container WORKDIR /app # Install necessary dependencies RUN apt-get update -y && apt-get install -y \ wget \ xvfb \ curl \ unzip \ jq \ libxss1 \ libappindicator1 \ libgconf-2-4 \ fonts-liberation \ libasound2 \ libnspr4 \ libnss3 \ libx11-xcb1 \ libxtst6 \ lsb-release \ xdg-utils \ libgbm1 \ libatk-bridge2.0-0 \ libgtk-3-0 \ libxcb-dri3-0 \ libgl1-mesa-glx \ libxrender1 \ libxcomposite1 \ libxi6 \ libxrandr2 \ libxcursor1 \ libxinerama1 # Download versions JSON and install Google Chrome RUN curl -s https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions-with-downloads.json > /tmp/versions.json && \ CHROME_URL=$(jq -r '.channels.Stable.downloads.chrome[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \ wget -q --continue -O /tmp/chrome-linux64.zip $CHROME_URL && \ unzip /tmp/chrome-linux64.zip -d /opt/chrome && \ chmod +x /opt/chrome/chrome-linux64/chrome # Install ChromeDriver RUN CHROMEDRIVER_URL=$(jq -r '.channels.Stable.downloads.chromedriver[] | select(.platform=="linux64") | .url' /tmp/versions.json) && \ wget -q --continue -O /tmp/chromedriver-linux64.zip $CHROMEDRIVER_URL && \ unzip /tmp/chromedriver-linux64.zip -d /opt/chromedriver && \ chmod +x /opt/chromedriver/chromedriver-linux64/chromedriver # Set environment variables ENV CHROME_BIN /opt/chrome/chrome-linux64/chrome ENV CHROMEDRIVER_DIR /opt/chromedriver ENV PATH $CHROMEDRIVER_DIR:$PATH ENV DISPLAY=:99 # Clean up RUN rm /tmp/chrome-linux64.zip /tmp/chromedriver-linux64.zip /tmp/versions.json # Default command to run tests CMD ["sh", "-c", "Xvfb :99 -ac & mvn clean test -Dwebdriver.chrome.driver=/opt/chromedriver/chromedriver-linux64/chromedriver -Dwebdriver.chrome.whitelistedIps='' -Dchrome.options.args='--headless --disable-gpu --no-sandbox --disable-dev-shm-usage --remote-allow-origins=* --disable-software-rasterizer --disable-features=VizDisplayCompositor'"] 

Context: I am using the above docker image inside my azure pipleine as container to run java selenium test cases.

Error:

no such element: Unable to locate element: {"method":"xpath","selector":"//a[@href='ExcelDataListOverall.asp']"} (Session info: chrome=129.0.6668.70) For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception Build info: version: '4.11.0', revision: '040bc5406b' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.119.1.el7.x86_64', java.version: '11.0.14.1' Driver info: org.openqa.selenium.chrome.ChromeDriver Command: [62eccac0565dae1b9e5321e8200627f3, findElement {using=xpath, value=//a[@href='ExcelDataListOverall.asp']}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 129.0.6668.70, chrome: {chromedriverVersion: 129.0.6668.70 (df87d5cf12b1..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:41060}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:cdp: ws://localhost:41060/devtoo..., se:cdpVersion: 129.0.6668.70, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true} Session ID: 62eccac0565dae1b9e5321e8200627f3 

Issue faced:

But that href element is getting launched when i run from my machine or from other windows server. I have increased timeout as well it is not working. And when i took snapshots of that i could that specific element is not loaded at all.**

Tested multiple way but failing. Any idea upon this** 

    1 Answer 1

    0

    I think here the problem is not in the docker because if it runs without error it does mean it runs all the commands and installs everything correctly here you need to add more wait for this element try to use Explicate wait for this particular element for 60 SC, in case the element exists and you can run the same test in your local.. try to use this xpath //a[contains(text(),'ExcelDataListOverall')]", also try to add another timeout wait driver. manage().timeouts().pageLoadTimeout(Duration.of seconds(60));

    also, ensure that the browser is hedless>true

    3
    • Nope i have increased the time out in chromesetting.java public WebDriver getDriver() { WebDriver driver = new ChromeDriver(addAll()); driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(60)); // 60 seconds for page load driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); // 10 seconds implicit wait return driver; } But still getting the error no such element: Unable to locate element: {"method":"xpath","selector":"//a[contains(text(),'ExcelDataListOverall')]"}
      – Subha
      CommentedOct 1, 2024 at 3:25
    • but try to run the same scenario in your local and check the result because the error does mean the element is not correct or not found so try to run the same in your local another way to ensure, try to get chropath extension if you are using Chrome and in the same page that includes this element and use //a[contains(text(),'ExcelDataListOverall')] and check how many elements there it should show 1 element found if the result is zero try to get the path of this element, may be the element into a frame so this way will help you to know if the element is existing or noCommentedOct 3, 2024 at 12:46
    • I was able to fix this issue when running as windows container. Linux container due to Linux OS at the backend doesn't support few frames.
      – Subha
      CommentedOct 18, 2024 at 4:43

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.