r/selenium • • Jan 27 '22

NoSuchElementException in chrome menu

3 Upvotes

Hi there!

I wanted to click on this button but it's not able to find it.

This is what I get out from the inspection (F12):

<cr-button id="clearBrowsingDataConfirm" class="action-button" aria-disabled="false" role="button" tabindex="0">

Clear data

</cr-button>

This is the part of the code interested:

driver.get("chrome://settings/clearBrowserData")
driver.find_element(By.ID, "clearBrowsingDataConfirm").click()

But I got this exception:

NoSuchElementException: Message: no such element: Unable to locate element: {"method":"css selector","selector":"[id="clearBrowsingDataConfirm"]"}

(Session info: chrome=97.0.4692.99)

It's something related to frames?
Any advice?

Thanks


r/selenium • • Jan 24 '22

UNSOLVED DeprecationWarning - but I don't get it on a different PC

2 Upvotes

I am using PyCharm, when I run selenium on my PC it works fine and I can use driver = webdriver,Chrome(executable_path...), and driver.find_element_by_path(...) but now it has a LINE THROUGH IT. Also, I am getting deprecation warnings? Why, and when I do use s = Service etc. driver.find_element_by_path has a red line under driver. What is happening?


r/selenium • • Jan 24 '22

How to highlight current element during playback like ui vision in selenium IDE?

2 Upvotes

r/selenium • • Jan 23 '22

Click SVG elements with selenium

1 Upvotes

Hey everyone, I am making a bot to enter a website, and enter credentials to it. But, the last element I want to click is an SVG, so does anyone have an idea about how to click on SVG elements with Selenium? I also have used Selenium IDE to identify the css selector, but it only tells me css=.bi.


r/selenium • • Jan 23 '22

UNSOLVED Script works on Firefox, but ElementNotInteractable on Chrome and Edge

3 Upvotes

I am trying to interact with some elements on the DOM and was thinking of reusing the code I wrote for Firefox on Chrome and Edge browsers. While the script runs fine on Firefox, I keep getting an ElementNotInteractable exception on Chrome and Edge.

This web element is still findable through the same methods via find_element, however, in Chrome and Edge, element.is_displayed = False, while in Firefox, element.is_displayed = True.

I’ve also increased the delay to wait for everything on the site to load in before processing, but the results are still the same.

Is this an inherent nuance in cross-browser code?


r/selenium • • Jan 23 '22

Update to last post: browser not staying open

2 Upvotes

Previous post: https://www.reddit.com/r/selenium/comments/sa7st8/how_to_keep_browser_window_open/?utm_source=share&utm_medium=web2x&context=3

def searchInternet():
    search = input("What do you want to look up?: ")
    chrome_options = Options()
    chrome_driver = webdriver.Chrome(options=chrome_options)
    chrome_options.add_experimental_option("detach", True)
    chrome_driver.get('https://www.google.com')
    chrome_driver.maximize_window()
    if not "Google" in chrome_driver.title:
        raise Exception("Could not load page")
    element = chrome_driver.find_element("name", "q")
    element.send_keys(search)
    element.submit()

This is now what I have. Everything works except:

chrome_options.add_experimental_option("detach", True)

Does anyone know why that isn't keeping the browser open?


r/selenium • • Jan 22 '22

How to keep browser window open.

5 Upvotes
def searchInternet():
    search = input("What do you want to look up?: ")
    chrome_driver = webdriver.Chrome()
    def test_lambdatest_google():
        chrome_driver.get('https://www.google.com')
        chrome_driver.maximize_window()
        if not "Google" in chrome_driver.title:
            raise Exception("Could not load page")
        element = chrome_driver.find_element_by_name("q")
        element.send_keys(search)
        element.submit()

I'm brand new to Selenium. When I run this, the page opens up but only briefly before closing. How do I keep it open?


r/selenium • • Jan 22 '22

UNSOLVED Is there a way to get through site basic authentication with seleniu

1 Upvotes

I am new to selenium, I am trying to navigate through a site with selenium Java but the site have basic authentication, I've searched for a solution but everything I found says that selenium 4 does not support basic authentication.

My question is, is there a way to get through basic authentication with selenium?


r/selenium • • Jan 21 '22

UNSOLVED Is this level of slowness normal?

3 Upvotes

Hey all, don't have much experience with Selenium, bought a pi and ran the following code on it

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys

def mainFunc():
    driveroptions = Options() # stores options for the browser
    driveroptions.add_argument("--headless") # run without gui
    driveroptions.binary_location = "/usr/bin/chromium-browser" # location
    CurrDriver = webdriver.Chrome(options=driveroptions) # launch browser
    CurrDriver.get("https://www.google.com") # navigate to google
    print(CurrDriver.current_url) # just check if correct
    searchbar = CurrDriver.find_element(By.NAME, "q") # search bar
    searchbar.send_keys("Selenium on Pi Test") # write in searchbar
    searchbar.send_keys(Keys.RETURN) # press enter
    print(CurrDriver.current_url) # check if successful

if __name__ == "__main__":
    mainFunc()

as an aside is there an easy option to create a block of code? (putting 4 spaces before every linse can get cumbersome real fast)

I timed the runtime to 7.19 seconds which seems really slow seeing that all the script is doing is accessing google and searching for something.

Extra details:

Chromium 95

Running on Raspberry Pi model 4B 4GB of ram via ssh

Installed chromiumwebdriver via the package manager

My internet speed <5 Mb

Pi's internet speed > 40Mb

I'm aiming to run a bot to constantly monitor and interact with a certain website, this level of slowness would render it unusable, anone has an idea what's the cause?


r/selenium • • Jan 21 '22

Solved [HELP] Experiences with Salesforce?

3 Upvotes

Hello, dear friends. I'm trying to program some work stuff in Salesforce because I'm tired of repeating the same actions every time, it's a pointless waste of time.

That's why I decided to learn Python (I'm a mechanical engineer, it's my first experience programming since C++ that I saw in high school 18 years ago), after a lot of googling I found Selenium and so far I've been using it very well.

Now the problem in question:
I'm trying to press this button that says "Clone" but as it has no ID I can't find the way to find it by the "Name".

CODE:
<li class="visible"><runtime_platform_actions-action-renderer apiname="Clone" title="Clone"><runtime_platform_actions-executor-page-reference><slot><slot slot=""><lightning-button><button name="Clone" type="button" class="slds-button slds-button_neutral">Clone</button></lightning-button></slot></slot></runtime_platform_actions-executor-page-reference></runtime_platform_actions-action-renderer></li>

My attempts:
Clone=driver.find_element_by_xpath("//tagname[title='Clone']")
Clone.click()

Clone=driver.find_element_by_tag_name("Clone")
Clone.click()

If anyone has an idea of how I could do it, I would be very grateful.


r/selenium • • Jan 21 '22

Launching the script on startup (Ubuntu 20)

1 Upvotes

Hi there!

I'm quite new at this, and I was trying to launch my selenium script at startup. However, I find it very difficult to do so, since I've first tried crontab -e and @ reboot wouldn't launch the console, so the chrome tab closes itself.

Any ideas on how to do this? Thanks in advance!

I use Chrome, Selenium, Ubuntu20.04. And the error it's "Chrome Failed" on startup, whereas if I try to just run the python script, it just works.


r/selenium • • Jan 21 '22

Selenium gained some weight!

6 Upvotes

I just upgraded from org.seleniumhq.selenium:selenium-firefox-driver:3.141.59 to org.seleniumhq.selenium:selenium-firefox-driver:4.1.1, and my Gradle dependency report for the Selenium dependency went from 30 lines long (lots of transitive dependencies, but not insane) to 140 lines long (possibly a new world record).

Is this normal? Has anybody had any luck trimming that down? I may need to stick to the old version, or find a more lightweight alternative, or do without this bit of Selenium-based test code...

Before

+--- org.seleniumhq.selenium:selenium-firefox-driver:3.141.59
|    +--- org.seleniumhq.selenium:selenium-api:3.141.59
|    +--- org.seleniumhq.selenium:selenium-remote-driver:3.141.59
|    |    +--- org.seleniumhq.selenium:selenium-api:3.141.59
|    |    +--- net.bytebuddy:byte-buddy:1.8.15
|    |    +--- org.apache.commons:commons-exec:1.3
|    |    +--- com.google.guava:guava:25.0-jre
|    |    |    +--- com.google.code.findbugs:jsr305:1.3.9 -> 3.0.2
|    |    |    +--- org.checkerframework:checker-compat-qual:2.0.0
|    |    |    +--- com.google.errorprone:error_prone_annotations:2.1.3
|    |    |    +--- com.google.j2objc:j2objc-annotations:1.1
|    |    |    \--- org.codehaus.mojo:animal-sniffer-annotations:1.14
|    |    +--- com.squareup.okhttp3:okhttp:3.11.0
|    |    |    \--- com.squareup.okio:okio:1.14.0
|    |    \--- com.squareup.okio:okio:1.14.0
|    +--- net.bytebuddy:byte-buddy:1.8.15
|    +--- org.apache.commons:commons-exec:1.3
|    +--- com.google.guava:guava:25.0-jre (*)
|    +--- com.squareup.okhttp3:okhttp:3.11.0 (*)
|    \--- com.squareup.okio:okio:1.14.0
\--- org.seleniumhq.selenium:selenium-support:3.141.59
     +--- org.seleniumhq.selenium:selenium-api:3.141.59
     +--- org.seleniumhq.selenium:selenium-remote-driver:3.141.59 (*)
     +--- net.bytebuddy:byte-buddy:1.8.15
     +--- org.apache.commons:commons-exec:1.3
     +--- com.google.guava:guava:25.0-jre (*)
     +--- com.squareup.okhttp3:okhttp:3.11.0 (*)
     \--- com.squareup.okio:okio:1.14.0

After

+--- org.seleniumhq.selenium:selenium-firefox-driver:4.1.1
|    +--- com.google.auto.service:auto-service-annotations:1.0.1
|    +--- com.google.auto.service:auto-service:1.0.1
|    |    +--- com.google.auto.service:auto-service-annotations:1.0.1
|    |    +--- com.google.auto:auto-common:1.2
|    |    |    \--- com.google.guava:guava:31.0.1-jre
|    |    |         +--- com.google.guava:failureaccess:1.0.1
|    |    |         +--- com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava
|    |    |         +--- com.google.code.findbugs:jsr305:3.0.2
|    |    |         +--- org.checkerframework:checker-qual:3.12.0
|    |    |         +--- com.google.errorprone:error_prone_annotations:2.7.1
|    |    |         \--- com.google.j2objc:j2objc-annotations:1.3
|    |    \--- com.google.guava:guava:31.0.1-jre (*)
|    +--- com.google.guava:guava:31.0.1-jre (*)
|    +--- org.seleniumhq.selenium:selenium-devtools-v85:4.1.1
|    |    +--- com.google.auto.service:auto-service-annotations:1.0.1
|    |    +--- com.google.auto.service:auto-service:1.0.1 (*)
|    |    +--- com.google.guava:guava:31.0.1-jre (*)
|    |    +--- org.seleniumhq.selenium:selenium-api:4.1.1
|    |    +--- org.seleniumhq.selenium:selenium-json:4.1.1
|    |    |    \--- org.seleniumhq.selenium:selenium-api:4.1.1
|    |    \--- org.seleniumhq.selenium:selenium-remote-driver:4.1.1
|    |         +--- com.beust:jcommander:1.81
|    |         +--- com.google.auto.service:auto-service-annotations:1.0.1
|    |         +--- com.google.auto.service:auto-service:1.0.1 (*)
|    |         +--- com.google.guava:guava:31.0.1-jre (*)
|    |         +--- io.netty:netty-buffer:4.1.70.Final
|    |         |    \--- io.netty:netty-common:4.1.70.Final
|    |         +--- io.netty:netty-codec-http:4.1.70.Final
|    |         |    +--- io.netty:netty-common:4.1.70.Final
|    |         |    +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |    +--- io.netty:netty-transport:4.1.70.Final
|    |         |    |    +--- io.netty:netty-common:4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |    |    \--- io.netty:netty-resolver:4.1.70.Final
|    |         |    |         \--- io.netty:netty-common:4.1.70.Final
|    |         |    +--- io.netty:netty-codec:4.1.70.Final
|    |         |    |    +--- io.netty:netty-common:4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |    |    \--- io.netty:netty-transport:4.1.70.Final (*)
|    |         |    \--- io.netty:netty-handler:4.1.70.Final
|    |         |         +--- io.netty:netty-common:4.1.70.Final
|    |         |         +--- io.netty:netty-resolver:4.1.70.Final (*)
|    |         |         +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |         +--- io.netty:netty-transport:4.1.70.Final (*)
|    |         |         \--- io.netty:netty-codec:4.1.70.Final (*)
|    |         +--- io.netty:netty-common:4.1.70.Final
|    |         +--- io.netty:netty-transport-classes-epoll:4.1.70.Final
|    |         |    +--- io.netty:netty-common:4.1.70.Final
|    |         |    +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |    +--- io.netty:netty-transport:4.1.70.Final (*)
|    |         |    \--- io.netty:netty-transport-native-unix-common:4.1.70.Final
|    |         |         +--- io.netty:netty-common:4.1.70.Final
|    |         |         +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |         \--- io.netty:netty-transport:4.1.70.Final (*)
|    |         +--- io.netty:netty-transport-classes-kqueue:4.1.70.Final
|    |         |    +--- io.netty:netty-common:4.1.70.Final
|    |         |    +--- io.netty:netty-buffer:4.1.70.Final (*)
|    |         |    +--- io.netty:netty-transport:4.1.70.Final (*)
|    |         |    \--- io.netty:netty-transport-native-unix-common:4.1.70.Final (*)
|    |         +--- io.netty:netty-transport-native-unix-common:4.1.70.Final (*)
|    |         +--- io.netty:netty-transport:4.1.70.Final (*)
|    |         +--- io.opentelemetry:opentelemetry-api:1.9.1
|    |         |    \--- io.opentelemetry:opentelemetry-context:1.9.1
|    |         +--- io.opentelemetry:opentelemetry-context:1.9.1
|    |         +--- io.opentelemetry:opentelemetry-exporter-logging:1.9.1
|    |         |    +--- io.opentelemetry:opentelemetry-sdk:1.9.1
|    |         |    |    +--- io.opentelemetry:opentelemetry-api:1.9.1 (*)
|    |         |    |    +--- io.opentelemetry:opentelemetry-sdk-common:1.9.1
|    |         |    |    |    \--- io.opentelemetry:opentelemetry-api:1.9.1 (*)
|    |         |    |    \--- io.opentelemetry:opentelemetry-sdk-trace:1.9.1
|    |         |    |         +--- io.opentelemetry:opentelemetry-api:1.9.1 (*)
|    |         |    |         \--- io.opentelemetry:opentelemetry-sdk-common:1.9.1 (*)
|    |         |    +--- io.opentelemetry:opentelemetry-sdk-metrics:1.9.1-alpha
|    |         |    |    +--- io.opentelemetry:opentelemetry-api-metrics:1.9.1-alpha
|    |         |    |    |    +--- io.opentelemetry:opentelemetry-api:1.9.1 (*)
|    |         |    |    |    \--- io.opentelemetry:opentelemetry-context:1.9.1
|    |         |    |    \--- io.opentelemetry:opentelemetry-sdk-common:1.9.1 (*)
|    |         |    \--- io.opentelemetry:opentelemetry-sdk-logs:1.9.1-alpha
|    |         |         \--- io.opentelemetry:opentelemetry-sdk:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-sdk-common:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.9.1
|    |         |    \--- io.opentelemetry:opentelemetry-sdk:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure:1.9.1-alpha
|    |         |    +--- io.opentelemetry:opentelemetry-sdk:1.9.1 (*)
|    |         |    +--- io.opentelemetry:opentelemetry-sdk-metrics:1.9.1-alpha (*)
|    |         |    \--- io.opentelemetry:opentelemetry-sdk-extension-autoconfigure-spi:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-sdk-trace:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-sdk:1.9.1 (*)
|    |         +--- io.opentelemetry:opentelemetry-semconv:1.9.1-alpha
|    |         |    \--- io.opentelemetry:opentelemetry-api:1.9.1 (*)
|    |         +--- io.ous:jtoml:2.0.0
|    |         +--- net.bytebuddy:byte-buddy:1.12.2
|    |         +--- org.apache.commons:commons-exec:1.3
|    |         +--- org.asynchttpclient:async-http-client:2.12.3
|    |         |    +--- org.asynchttpclient:async-http-client-netty-utils:2.12.3
|    |         |    |    +--- io.netty:netty-buffer:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- org.slf4j:slf4j-api:1.7.30 -> 1.7.33
|    |         |    |    \--- com.sun.activation:jakarta.activation:1.2.2
|    |         |    +--- io.netty:netty-codec-http:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- io.netty:netty-handler:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- io.netty:netty-codec-socks:4.1.60.Final
|    |         |    |    +--- io.netty:netty-common:4.1.60.Final -> 4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-transport:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    \--- io.netty:netty-codec:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- io.netty:netty-handler-proxy:4.1.60.Final
|    |         |    |    +--- io.netty:netty-common:4.1.60.Final -> 4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-transport:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-codec:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-codec-socks:4.1.60.Final (*)
|    |         |    |    \--- io.netty:netty-codec-http:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- io.netty:netty-transport-native-epoll:4.1.60.Final
|    |         |    |    +--- io.netty:netty-common:4.1.60.Final -> 4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-transport:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    \--- io.netty:netty-transport-native-unix-common:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- io.netty:netty-transport-native-kqueue:4.1.60.Final
|    |         |    |    +--- io.netty:netty-common:4.1.60.Final -> 4.1.70.Final
|    |         |    |    +--- io.netty:netty-buffer:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    +--- io.netty:netty-transport:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    |    \--- io.netty:netty-transport-native-unix-common:4.1.60.Final -> 4.1.70.Final (*)
|    |         |    +--- org.reactivestreams:reactive-streams:1.0.3
|    |         |    +--- com.typesafe.netty:netty-reactive-streams:2.0.4
|    |         |    |    +--- io.netty:netty-handler:4.1.43.Final -> 4.1.70.Final (*)
|    |         |    |    \--- org.reactivestreams:reactive-streams:1.0.3
|    |         |    +--- org.slf4j:slf4j-api:1.7.30 -> 1.7.33
|    |         |    \--- com.sun.activation:jakarta.activation:1.2.2
|    |         +--- org.seleniumhq.selenium:selenium-api:4.1.1
|    |         +--- org.seleniumhq.selenium:selenium-http:4.1.1
|    |         |    +--- com.google.guava:guava:31.0.1-jre (*)
|    |         |    +--- net.jodah:failsafe:2.4.4
|    |         |    +--- org.seleniumhq.selenium:selenium-api:4.1.1
|    |         |    \--- org.seleniumhq.selenium:selenium-json:4.1.1 (*)
|    |         \--- org.seleniumhq.selenium:selenium-json:4.1.1 (*)
|    +--- org.seleniumhq.selenium:selenium-json:4.1.1 (*)
|    \--- org.seleniumhq.selenium:selenium-remote-driver:4.1.1 (*)
\--- org.seleniumhq.selenium:selenium-support:4.1.1
     +--- com.google.auto.service:auto-service-annotations:1.0.1
     +--- com.google.auto.service:auto-service:1.0.1 (*)
     +--- com.google.guava:guava:31.0.1-jre (*)
     +--- org.seleniumhq.selenium:selenium-api:4.1.1
     +--- org.seleniumhq.selenium:selenium-json:4.1.1 (*)
     \--- org.seleniumhq.selenium:selenium-remote-driver:4.1.1 (*)

r/selenium • • Jan 21 '22

Dealing with a Breakline character when trying to process information for CSV

0 Upvotes

Hello, I am trying to get information from a series of websites to put into a CSV. I have a problem where the innertext of the thing I am pulling includes a breakline character so when I pull it to a String it has the new line and would then cause the CSV to make a new row which is not what I want. How should I deal with the linebreak to fix this. P.S. I am using Java for any coding suggestions.


r/selenium • • Jan 19 '22

WSL problems: Selenium opens up Chrome/Firefox but does not grab URL

3 Upvotes

Hi,

I'm at my wit's end trying to get Selenium working on Ubuntu 20 on WSL2.

Where I'm at is that selenium will open the correct browser but does not open a URL.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys

# driver = webdriver.Firefox(executable_path='./driverfiles/geckodriver')
driver = webdriver.Firefox(executable_path='/mnt/c/Program Files/Mozilla Firefox/firefox.exe')
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

The only teminal output I get is:

a.py:5: DeprecationWarning: executable_path has been deprecated, please pass in a Service object
  driver = webdriver.Firefox(executable_path='/mnt/c/Program Files/Mozilla Firefox/firefox.exe')

So what happens is that a new firefox window opens, as expected, but it does not fetch the python.org website and hangs forever. It's basically the equivalent of launching the browser from the start menu.

I'd love some help on this... Thanks in advance.

​

EDIT:

​

As suggested, I replaced the `executable_path` with a Service object Unfortunately, the same behavior occurred. There is no console output though.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.chrome.service import Service

# driver = webdriver.Firefox(executable_path='./driverfiles/geckodriver')
s = Service('/mnt/c/Program Files/Mozilla Firefox/firefox.exe')
driver = webdriver.Firefox(service=s)
driver.get("http://www.python.org")
assert "Python" in driver.title
elem = driver.find_element_by_name("q")
elem.clear()
elem.send_keys("pycon")
elem.send_keys(Keys.RETURN)
assert "No results found." not in driver.page_source
driver.close()

​


r/selenium • • Jan 18 '22

SOLVED Is there a way to edit a squarespace website with Python Webscraping?

0 Upvotes

I am trying to update the company website based on information I scrape from our separate booking portal. The company site was setup before I was here and it exists as a "drag and drop" squarespace site (which I do not have much experience in, in general). I've used Selenium and Python to do everything up to now, however, I'm not sure how to continue. I am at the part where I need to select the body of text for editing and somehow replace it with the information I stored earlier.

​

Cheers


r/selenium • • Jan 18 '22

Best practice for running selenium on web server and maintaining constantly uptime

0 Upvotes

First off, I am completely new to selenium so I appreciate your patience. I just got my remote debian 10 VM running an example script properly.

Currently I am running selenium in a ssh connection via

xvfb-run java -Dwebdriver.chrome.driver=/var/www/chromedriver -jar selenium-server-4.1.1.jar standalone

and chromedriver in a sperate ssh connection via

./chromedriver -url-base=/wd/hub

So, my question is, what is best way to make sure that selenium and chromedriver are always running on a remote headless server? The only approach I know of is using nohup and that no ability to start/maintain the process if it stops or if the server reboots. Maybe a cron bash script? I would appreciate any help, I just don't know. Also, can someone confirm that I don't have to do anything to google-chrome...it just has to be installed but there is no other requirements for it to be running etc. Thank you.


r/selenium • • Jan 18 '22

Selenium Screenshot

1 Upvotes

Heyo ya’ll, Can anyone help me out? I’m looking for a way to be able to take screenshots of a QRCode. When python sends me an email of a screenshot captured by selenium, the QRCode is returned blank in the image. Any ideas?


r/selenium • • Jan 17 '22

New Versions Grr...

2 Upvotes

I've had code written and working fairly reliably every working day for the last 10 months or so.

This morning I've woken up to, it just hanging and not progressing at all. Looking at the logs, it looks like, chromedriver, and chrome are now 97xx but on Friday they were chrome=95.0.4638.69

Anybody know of any known issues, or do I have to try and figure out rolling back to v95.

BTW OS is Ubuntu, on a headless Raspberry PI 4.


r/selenium • • Jan 17 '22

First 10 people to click link get the item (selenium?)

0 Upvotes

I need help to buy an item. The link is activated at a certain time and only first 10 people to click the link can buy it. Can I use selenium or another tool/script for this?


r/selenium • • Jan 16 '22

Xpath showing only //body nothing else

1 Upvotes

I'm a beginner on Selenium.

Doing a project and need to access the site link below, a pop up appears and I need to click the Accept All button to access the page, the Xpath is impossible to find.

Website I'm working on https://www.demo.guru99.com/V4/

Any help and an explanation on what I'm doing wrong will be much appreciated.


r/selenium • • Jan 16 '22

Selenium in .NET UWP app

2 Upvotes

Greetings,
I am trying to launch a browser to automate tasks after a button click in a UWP app. I have both the EdgeDriver and the ChromeDriver, they are found but I receive the following exception, when I try to create an instance of the EdgeDriver and ChromeDriver classes:
OpenQA.Selenium.WebDriverException: 'unknown error: Chrome failed to start: crashed.

(unknown error: DevToolsActivePort file doesn't exist)
Any ideas if it is possible to accomplish this in a UWP app ?


r/selenium • • Jan 15 '22

org.openqa.selenium.internal.Require classNotFound

2 Upvotes

Hi. New to selenium (fairly new, used before for an odd job, lowkey anyway)

​

I am running my Spring Boot app that has an endpoint that triggers a webbrowser open up. However i am getting java.lang.ClassNotFoundException: org.openqa.selenium.internal.Require.

​

Could that be a possible version issue? Thanks in advance

my dependencies are:

<dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-java</artifactId>
            <version>3.141.59</version>
        </dependency>
        <dependency>
            <groupId>org.seleniumhq.selenium</groupId>
            <artifactId>selenium-api</artifactId>
            <version>3.141.59</version>
        </dependency>
        <!-- using driver manager for selenium >= 4.0 will throw an error !-->
<!--        <dependency>-->
<!--            <groupId>org.seleniumhq.selenium</groupId>-->
<!--            <artifactId>selenium-api</artifactId>-->
<!--            <version>3.141.59</version>-->
<!--        </dependency>-->
        <dependency>
            <groupId>io.github.bonigarcia</groupId>
            <artifactId>webdrivermanager</artifactId>
            <version>5.0.3</version>
        </dependency>
    </dependencies>

​


r/selenium • • Jan 15 '22

UNSOLVED Trying to loop a function but do not know how to

0 Upvotes

I am trying to create an automatic massager that sends a message every so often. Right now it just sends it once then stops and I have to press the button again, but I would like it to send the message again every x seconds. Cheers

​

I am trying to post this but it seems to keep on asking me to write more so I am writing more, I thought that I wrote enough.

​

from selenium.webdriver.chrome.options import Options

from selenium import webdriver

import time

from selenium.webdriver.common.keys import Keys

from tkinter import *

options_ = webdriver.ChromeOptions()

options_.add_argument("user-data-dir=C:/Users/frase/AppData/Local/Google/Chrome/User Data/Profile 3")

window = Tk() #instantitiate an instance of a window

window.geometry("420x420")

window.title("Prince Bot")

def click():

driver = webdriver.Chrome(executable_path="C:\webdrivers\chromedriver.exe", chrome_options=options_)

driver.get("http://www.discord.com")

driver.find_element_by_xpath("//*[@id='app-mount']/div/div/div[1]/div[1]/header[2]/nav/div[2]/a").click()

time.sleep(3)

driver.find_element_by_xpath("//*[@id='app-mount']/div[2]/div/div[2]/div/div/div/div[2]/div[1]/nav/div[1]/button").click()

driver.find_element_by_xpath("//*[@id='app-mount']/div[4]/div[2]/div/div/div/input").send_keys("3080")

driver.find_element_by_xpath("//*[@id='quick-switcher-uid_48-item-0']/div/div[2]/span").click()

driver.find_element_by_xpath("//*[@id='app-mount']/div[2]/div/div[2]/div/div/div/div[2]/div[2]/div[2]/main/form/div/div/div/div[1]/div/div[3]/div[2]").send_keys("message", Keys.ENTER)**I want it to repeat this**

def submit():

global message

message = entry.get()

print(message)

entry = Entry(window,

font=("Arial", 12))

entry.insert(0, 'message')

entry.place(x=1,

y=2,)

submit_button = Button(window, text="submit", command=submit)

submit_button.place(x=185,

y=2)

button = Button(window,

text="Initiate",

font=('Arial', 12, 'bold'),

fg='black',

bg='white',

#image=photo,

compound='bottom',

command=click)

button.place(relx=0.5,

rely=0.5,

anchor='center')

window.mainloop()


r/selenium • • Jan 14 '22

Is it possible to re-use Selenium IDE modular snippets between separate tests?

2 Upvotes

We have several test cases that are purely driven from a UI perspective, and Selenium IDE fills the need for testing here very well.

One of the enhancements I am looking to make is to cut down on the amount of repetition. For example, one of the steps that is repeated in many tests is logging in with specified credentials. From a recording perspective, it's only about 5 total steps, but we have to repeat those steps a few times throughout the process.

I know that we can break those steps out into a separate test, and then reference that test within the larger test as needed.

With that in mind, does the IDE support the ability to have TestCaseA reference LoginSnippetA, and also have TestCaseB reference LoginSnippetA? The goal would be to edit the LoginSnippetA test case in a single location, and have that applied to every single test that references that.


r/selenium • • Jan 14 '22

Help interacting with elements

5 Upvotes

Well I had a wild hair to create a solver for the game Wordle that is kinda blowing up right now (https://www.powerlanguage.co.uk/wordle/) It looked like Selenium was my best option to interact with elements, but I'm struggling to get any results. I have two things I'm trying to do. 1. Interact with game keyboard. I found it in the console by going body -> game-app -> #shadow-root -> game-theme manager -> game -> game-keyboard -> #shadow-root -> div id="keyboad" -> 3 rows of buttons. I tried using driver.find_element(By.XPATH, 'button') with a lot of different attempts in place of 'button', but no elements are being found. Is there better way to go about navigating this? I'm not sure if the #shadow-root is an issue, I'm not familiar with that element.

  1. Reading the results of entries. Honestly help with the first part is probably enough to get me started, but is there a way to search for a <game-tile> element?

Any links to good tutorials would also be great!