After test:report:chrome Report generation done, Terminal not closing the instance, it keeps running
I am using protector, selenium for running the UI automation.
For chrome driver I am using webdriver-manager for testing the UI Automation. It run successfully, browser also close but it keeps running the terminal instance can anyone help me on this?
config.directConnect = false;
config.seleniumAddress = "http://127.0.0.1:4444/wd/hub";
config.capabilities.chromeOptions = chromeOptions = {
args: [
"--no-sandbox",
"--disable-infobars",
"--disable-dev-shm-usage",
"--disable-extensions",
"--log-level=3",
"--disable-gpu",
"--start-maximized"
].concat(isCI ? ["--headless"] : []), // run in headless mode on the CI server
prefs: {
"download.default_directory": downloadDir
}
};
config.serenity = {
outputDirectory: `${process.cwd()}/test_reports_chrome`,
runner: "cucumber",
crew: [
ArtifactArchiver.storingArtifactsAt("./test_reports_chrome"),
ConsoleReporter.forDarkTerminals(),
Photographer.whoWill(TakePhotosOfInteractions), // or Photographer.whoWill(TakePhotosOfFailures),
new SerenityBDDReporter()
]
do you know?
how many words do you know
See also questions close to this topic
-
how to change prettier format for react native
my code formatting prettier didn't works well for react native, i don't understand where to config it but it works well with flutter
from this code
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( <View> <Text>Apps</Text> </View> ) }
it's formatted to this
import { View, Text } from 'react-native' import React from 'react' export default function App() { return ( < View > < Text > Apps < /Text> < /View> ) }
-
react-router-dom v6 params only numbers
I want add number regex in may param in react-router-dom v6. it work fin in v5 like it:
<Route path="list/:id(\d+)" element={<MyComponent/>} />
but it not work in v6.
-
How can I fixed my problem"FirebaseError: Firebase: Error (auth/invalid-api-key)."
My environment variable is ok. No comas and name mistakes but they given me error like "FirebaseError: Firebase: Error (auth/invalid-api-key)". How can I fixed it. Please Help me...
This my .env file
REACT_APP_apiKey=AIzaSyBWobnhbdeMdNpXXXXXXXXXXXXXXXXXXXX REACT_APP_authDomain=XXXXX.firebaseapp.com REACT_APP_projectId=XXXX REACT_APP_storageBucket=XXXXX.appspot.com REACT_APP_messagingSenderId=4997390XXXXX REACT_APP_appId=1:4997390XXXXX:web:cc7bc80aa1bdb78fXXXXXX REACT_APP_measurementId=G-M1XDXXXXXX
This my firebase config file
const firebaseConfig = { apiKey: process.env.REACT_APP_apiKey, authDomain: process.env.REACT_APP_authDomain, projectId: process.env.REACT_APP_projectId, storageBucket: process.env.REACT_APP_storageBucket, messagingSenderId: process.env.REACT_APP_messagingSenderId, appId: process.env.REACT_APP_appId, measurementId: process.env.REACT_APP_measurementId, }; when I debugging firebaseConfig object console.log(firebaseConfig.apiKey); ==========> undefined console.log(firebaseConfig.authDomain); ==========> undefined console.log(firebaseConfig.projectId); ==========> undefined console.log(firebaseConfig.storageBucket); ==========> undefined console.log(firebaseConfig.measurementId); ==========> undefined console.log(firebaseConfig.appId); ==========> undefined console.log(firebaseConfig.measurementId); ==========> undefined
client side given error this "FirebaseError: Firebase: Error (auth/invalid-api-key)"
-
It won't let me run selenium code in IntellJ all of a sudden
I was going to execute my code, which is the one I always execute every day for my tests, but suddenly this error appears and I have hardly found a solution, I don't know if it is possible that you can help me with that, I attach the response from the console
Starting ChromeDriver 102.0.5005.27 (df4a85108ffad4dca2c409c52f24df7ec0204b91-refs/branch-heads/5005_22@{#4}) on port 33567 Only local connections are allowed. Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe. ChromeDriver was started successfully. Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created: This version of ChromeDriver only supports Chrome version 102 Current browser version is 101.0.4951.54 with binary path C:\Program Files\Google\Chrome\Application\chrome.exe Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03' System info: host: 'DESKTOP-V4H61F7', ip: '192.168.56.1', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '17.0.2' Driver info: driver.version: ChromeDriver remote stacktrace: Backtrace: Ordinal0 [0x003B2733+2434867] Ordinal0 [0x003407A1+1968033] Ordinal0 [0x0022C678+837240] Ordinal0 [0x0024CAC3+969411] Ordinal0 [0x002486DA+952026] Ordinal0 [0x00245F91+941969] Ordinal0 [0x002790B0+1151152] Ordinal0 [0x00278D0A+1150218] Ordinal0 [0x00274256+1131094] Ordinal0 [0x0024E840+976960] Ordinal0 [0x0024F736+980790] GetHandleVerifier [0x00623C72+2515426] GetHandleVerifier [0x0061702F+2463135] GetHandleVerifier [0x0045522A+620442] GetHandleVerifier [0x00454016+615814] Ordinal0 [0x0034707B+1994875] Ordinal0 [0x0034B938+2013496] Ordinal0 [0x0034BA25+2013733] Ordinal0 [0x00354DE1+2051553] BaseThreadInitThunk [0x7632FA29+25] RtlGetAppContainerNamedObjectPath [0x77E87A7E+286] RtlGetAppContainerNamedObjectPath [0x77E87A4E+238] at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at org.openqa.selenium.remote.W3CHandshakeResponse.lambda$errorHandler$0(W3CHandshakeResponse.java:62) at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30) at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126) at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) at java.base/java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:1002) at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129) at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527) at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513) at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150) at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128) at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136) at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552) at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213) at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168) at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:123) at Selenium.pruebas_activity21.main(CrearOT.java:28) Process finished with exit code 1
I hope you can help me with it. It doesn't say any relevant changes, but it seems that any code I'm trying to do can no longer be executed.
-
Selenium Python - loop gets slower everytime
Im trying to automize downloading files, from a list of "cars" then save the file on my computer unzip it and rename it with the name of the car.
Problem is, my forloop is getting increasingly slower. The first loop takes about 1 second to execute, but the 10th loop takes almost a minute.
Could someone review my code and point out potential flaws? i'm using chromedriver.
for car in carList: try: #Apre il filter filter = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, '//*[contains(text(), "filter")]')) ) filter.click() #Find car n_sport = WebDriverWait(driver, 10).until( EC.presence_of_element_located((By.CSS_SELECTOR, '#door')) ) n_sport.send_keys(car) n_sport.send_keys(Keys.ENTER) #open_car = driver.find_element_by_xpath("//a[contains(@title," + "0" +car +")]") open_car = WebDriverWait(driver, 30).until( EC.element_to_be_clickable((By.XPATH, "//a[contains(@title," + "0" +car +")]") )) open_car.click() ##driver.execute_script("arguments[0].click();", checkbox_elem) #open file system fs = WebDriverWait(driver, 30).until( EC.element_to_be_clickable((By.XPATH, '//*[contains(text(), "file system")]')) ) fs.click() #open C: c = WebDriverWait(driver, 60).until( EC.element_to_be_clickable((By.XPATH, '//*[contains(text(), "C:")]')) ) c.click() #Right click on file: f = WebDriverWait(driver, 60).until( EC.element_to_be_clickable((By.XPATH, textToSearch)) ) ActionChains(driver).context_click(f).perform() #Save save = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, '//*[contains(@href, "#GETFILE")]')) ) save.click() #Find empty button: empty = WebDriverWait(driver, 10).until( EC.element_to_be_clickable((By.XPATH, '//*[contains(text(), "Svuota elenco")]')) ) #Empty empty.click() print('The file has been downloaded from the car: ' + car ) if doesZipExists: renameFile(parentFolder, ext, car, fname) except: print('Error: car ' + car + ' has not been found')
-
Selenium C# - Recording how chrome driver do a test case
At this moment, in my tests I use Screenshots to locate where my test failed.. Screenshot is only taken while, test fails. Sometimes it is difficult to find a place where the test failed exactly. That's why I am thinking about start recording chrome driver's work. I could take failed tests, take their records/videos and check on the screen through video what was wrong in each failed case.
I found some solutions that won't work today, for example:
- Screen Recorder - there is no available Microsoft Expression Encoder 4 today.
- Some solutions have problems with Headless mode.
I want to start recording after create chrome driver (in each test case), than through test's steps and stop recording on the end of each test case. I am going to check result of test case (Failed, Blocked, PASS). Than I am going to save video (in any location) if test failed/blocked and delete the video if test case PASSED.
Do you have any ideas to record driver's work ?
-
Python Web Scraping extract results from Post
I'm using Python \ Selenium \ Chrome Driver
I'm just after some advice, is it actually possible to perform a POST in Python via requests and then actually extract data from the result? Also through into the mix the webpage is rendered via Javascript so I need to render it first.
For a GET I can perform this via Beautiful Soup using the Chrome driver, but for some reason I just cannot get it to work via requests. (As I understand driver does not support POST??)
For eg:
payload = {'Id': 12345} url = requests.post('https://mywebsite//RecordRest/getTransaction', data=payload) print("Status code: ", url.status_code)
For example, when I execute the above I do get a 200 response, but its actually then extracting the data from the webpage - which is in JSON.
I'm just wondering if this is possible via a POST as I've been spending a lot of time on this and cannot seem to get it to work.
Any pointers or suggestions would be helpful.
-
Why am I getting a deprecated warning when using this xpath syntax?
I am using selenium to print all of the product links on a webpage. Here is my code:
from selenium.webdriver import Chrome driver_path = PATH = r"C:\Users\David\Desktop\Selenium\chromedriver.exe" driver = Chrome(executable_path=driver_path) driver.get('https://www.lazada.com.ph/shop-portable-speakers/?spm=a2o4l.home.cate_2_2.2.239e359dxynAFV' ) xpath = '//*[@id="root"]/div/div[2]/div[1]/div/div[1]/div[2]' link_elements = driver.find_elements_by_xpath(xpath) links = [] for link_el in link_elements: href = link_el.get_attribute("href") print (href) links.append(href) driver.quit()
The code runs and prints the following:
runfile('C:/Users/David/Desktop/Selenium/untitled1.py', wdir='C:/Users/David/Desktop/Selenium') C:\Users\David\Desktop\Selenium\untitled1.py:4: DeprecationWarning: executable_path has been deprecated, please pass in a Service object driver = Chrome(executable_path=driver_path) C:\Users\David\Desktop\Selenium\untitled1.py:10: DeprecationWarning: find_elements_by_* commands are deprecated. Please use find_elements() instead link_elements = driver.find_elements_by_xpath(xpath) None
Any ideas as to what I am doing wrong here?.
-
Selenium Webdriver gives JSONDecodeError
I am trying to run sample codes using selenium and webdriver manager from the following site: https://pypi.org/project/webdriver-manager/. I am using google chrome, i tried the following codes:
Selenium version: 4.1.0
webdriver_manager version: 3.5.2
# code for chrome # Selenium 4 from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()))
I also tried:
# code for chromium # selenium 4 from selenium import webdriver from selenium.webdriver.chrome.service import Service from webdriver_manager.chrome import ChromeDriverManager from webdriver_manager.utils import ChromeType driver = webdriver.Chrome(service=Service(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install()))
Unfortunately i get the following error (it's similar for both codes):
JSONDecodeError Traceback (most recent call last) 5 from webdriver_manager.utils import ChromeType 6 ----> 7 driver = webdriver.Chrome(service=Service(ChromeDriverManager(chrome_type=ChromeType.CHROMIUM).install())) C:\ProgramData\Anaconda3\lib\site-packages\webdriver_manager\chrome.py in install(self) 30 31 def install(self): ---> 32 driver_path = self._get_driver_path(self.driver) 33 34 os.chmod(driver_path, 0o755) C:\ProgramData\Anaconda3\lib\site-packages\webdriver_manager\manager.py in _get_driver_path(self, driver) 21 driver_name = driver.get_name() 22 os_type = driver.get_os_type() ---> 23 driver_version = driver.get_version() 24 25 binary_path = self.driver_cache.find_driver(browser_version, driver_name, os_type, C:\ProgramData\Anaconda3\lib\site-packages\webdriver_manager\driver.py in get_version(self) 39 driver_version = self._version 40 if driver_version == "latest": ---> 41 return self.get_latest_release_version() 42 return self._version 43 C:\ProgramData\Anaconda3\lib\site-packages\webdriver_manager\driver.py in get_latest_release_version(self) 72 verify=self.ssl_verify 73 ) ---> 74 validate_response(resp) 75 self._version = resp.text.rstrip() 76 return self._version C:\ProgramData\Anaconda3\lib\site-packages\webdriver_manager\utils.py in validate_response(resp) 81 elif resp.status_code != 200: 82 raise ValueError( ---> 83 f'response body:\n{resp.json()}\n' 84 f'request url:\n{resp.request.url}\n' 85 f'response headers:\n{dict(resp.headers)}\n' C:\ProgramData\Anaconda3\lib\site-packages\requests\models.py in json(self, **kwargs) 908 # used. 909 pass --> 910 return complexjson.loads(self.text, **kwargs) 911 912 @property C:\ProgramData\Anaconda3\lib\json\__init__.py in loads(s, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 344 parse_int is None and parse_float is None and 345 parse_constant is None and object_pairs_hook is None and not kw): --> 346 return _default_decoder.decode(s) 347 if cls is None: 348 cls = JSONDecoder C:\ProgramData\Anaconda3\lib\json\decoder.py in decode(self, s, _w) 335 336 """ --> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 338 end = _w(s, end).end() 339 if end != len(s): C:\ProgramData\Anaconda3\lib\json\decoder.py in raw_decode(self, s, idx) 353 obj, end = self.scan_once(s, idx) 354 except StopIteration as err: --> 355 raise JSONDecodeError("Expecting value", s, err.value) from None 356 return obj, end JSONDecodeError: Expecting value: line 1 column 1 (char 0)
-
Selenium, WebDriver Manager, and Electron Desktop Apps
I'm building out some ui automation tests for an electron app. I have an existing test framework built in C# using Selenium and Appium for web and mobile devices. I figured out how to start the chrome driver and target the electron app, but to do so, I had to not use the extremely handy WebDriverManager package.
This is my set up
[SetUp] public void TestSetUp() { ChromeOptions chromeOptions = new() { BinaryLocation = @"ElectronApp.exe", }; _driver = new ChromeDriver(@"local driver path", chromeOptions); }
This works to open up the electron app using Chrome driver. I did have to match the version of Chrome the electron app used and made sure to download that version of the webdriver.
What I want to know is if there's a good way to use WebDriver Manager to set up my driver, but open the electron app.
This was what I was trying:
[SetUp] public void TestSetUp() { ChromeOptions chromeOptions = new() { BinaryLocation = @"ElectronApp.exe", }; ChromeConfig chromeConfig = new(); new WebDriverManager.DriverManager().SetUpDriver(chromeConfig, "98.0"); _driver = new ChromeDriver(chromeOptions);
The 98 is the version of Chrome that the electron app is apparently using -- that's the same version I had to match the driver for.
This is the stack error:
Message: System.Net.WebException : The remote server returned an error: (404) Not Found. TearDown : System.NullReferenceException : Object reference not set to an instance of an object. Stack Trace: HttpWebRequest.GetResponse() WebClient.GetWebResponse(WebRequest request) WebClient.DownloadBits(WebRequest request, Stream writeStream) WebClient.DownloadFile(Uri address, String fileName) BinaryService.DownloadZip(String url, String destination) BinaryService.SetupBinary(String url, String zipPath, String binaryPath) DriverManager.SetUpDriverImpl(String url, String binaryPath) DriverManager.SetUpDriver(IDriverConfig config, String version, Architecture architecture) DesktopTests.TestSetUp() line 41 --TearDown DesktopTests.Teardown() line 54