Protractor file upload working in Windows but script timeout in Linux - protractor

Im having a protractor test in which I upload a .csv File. It's working fine in Windows but in Linux im getting a Script Timeout.
I debugged the filepath and it looks good. I also set waitForAngular(false) before the upload and enabled it afterwards.
My Test:
describe('something', () => {
it('somethingElse', async () => {
await browser.get("https://somedomain.com");
await browser.driver.sleep(2000);
await browser.wait(EC.visibilityOf($('mat-card-content')),5000);
var fileToUpload = '../ressources/file.csv';
var filepath = path.resolve(__dirname, fileToUpload);
let importBtn = element(by.css('input[type="file"]'));
await importBtn.sendKeys(filepath);
...
})
})
The filepath with Windows:
C:\Users\mat\project\ressources\file.csv
The filepath with Linux:
/home/user/project/ressources/file.csv
My Error Message:
ScriptTimeoutError: script timeout: result was not received in 100 seconds
(Session info: headless chrome=74.0.3729.131)
(Driver info: chromedriver=74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}),platform=Linux 4.15.0-1023-aws x86_64)
at Object.checkLegacyResponse (/jenkins/workspace/Protractor_Stage/node_modules/selenium-webdriver/lib/error.js:546:15)
at parseHttpResponse (/jenkins/workspace/Protractor_Stage/node_modules/selenium-webdriver/lib/http.js:509:13)
at doSend.then.response (/jenkins/workspace/Protractor_Stage/node_modules/selenium-webdriver/lib/http.js:441:30)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:189:7)
And then just giving me the describe/it lines.

Related

unable to upload folder with files using protractor for web application testing

Iam using protractor for testing my web application that has a button to popup window to open file explorer where I need to select a folder that contains 5 files that needs to be uploaded.
I have the code as
''''
var fileUpload = '/home/indu/jpg';
require("./logger");
console.file("./test.log");
var absolutePath = path.resolve(__dirname, fileUpload);
fs.readdir(absolutePath, (err, files) => {
for (i = 0; i < files.length; i++) {
filelst.push(fileUpload +"/"+files[i]);
}
console.log("fuull is ",filelst);
});
var remote = require('/usr/lib/node_modules/protractor/node_modules/selenium-webdriver/remote');
browser.setFileDetector(new remote.FileDetector());
var absolutePath = path.resolve(__dirname, fileUpload);
console.log("value of absolutePath",absolutePath);
var fileElem = element(by.css('input[type="file"]'));
// Unhide file input
browser.executeScript("arguments[0].style.visibility = 'visible'; arguments[0].style.height = '1px'; arguments[0].style.width = '1px'; arguments[0].style.opacity = 1", fileElem.getWebElement());
fileElem.sendKeys(absolutePath);
when I execute I get below error
Failed: unexpected alert open: {Alert text : Error during upload, redirecting to login page .... }
(Session info: chrome=96.0.4664.110): Error during upload, redirecting to login page ....
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:25:53'
System info: host: 'indu-Latitude-E6420', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '5.4.0-91-generic', java.version: '1.8.0_312'
Driver info: driver.version: unknown
I have tried on windows10 as well as ubuntu 18.04.05 and on both I get chrome driver info version unknown error. I have searched for this error and tried suggested solution in
Unable to start e2e tesing in angular project
but that didnt work too.
Pls suggest
I resolved the problem by a
browser.wait(ExpectedConditions.elementToBeClickable(buttonelementlocator),
100, 'Element is not clickable.').then( () => {
uploadfiles();
});
function uploadfiles(){
var shell = require('shelljs');
var exec = require('child_process').execFile;
// uploadfile.bat contains the autoit exe to upload the files and handle
chromebrowser alert
var task = shell.exec('uploadfile.bat');
if (task.code !== 0) {
console.log("execute AutoIt script fail: " + task.stdout);
shell.exit(1);
}
}

Future not completed on PostgreSQL + Dart

I have got follow code:
void main() async {
connection = PostgreSQLConnection('localhost', 5432, 'db', username: 'postgres', password: '12345');
await connection.open();
//...
// some http handler that have next code inside:
List<List<dynamic>> result = await connection.query(body['sql']).timeout(Duration(seconds: 90));
If I run a lot of queries to http handler I am getting error:
TimeoutException after 0:00:30.000000: Future not completed
It's very strange, because on query I have timeout 90 seconds. So it's happens on connection. But I am opening connection only once in main.
Could anybody explain how it's happens? And how to fix it?
PostgreSQLConnection has parameters: timeoutInSeconds and queryTimeoutInSeconds and they both default to 30. I suggest you use them instead of timeout of Future.

Flutter: Connecting to localhost:5001 with http package from local device doesn't work

I have the following problem: I have a .NET API running on my local machine at https://localhost:5001. When I execute a request in Postman, it works totally fine, but when executing the same API call in Dart, it won't work.
In Postman https://localhost:5001 will respond with a 401 or a 200 Statuscode.
When I execute the exact same URL in Flutter, it will give me a timeout:
Flutter Devtools
When using https://localhost:5001 in Flutter -> SocketException: OS Error: Connection refused, errno = 111, address = localhost, port = 41838
When using https://192.168.0.154:5001 in Flutter -> SocketException: OS Error: Connection timed out, errno = 110, address = 192.168.0.154, port = 44624
Im executing the following code:
var response = await http.get(url);
if(response.statusCode == 200) {
print(response.body);
}else{
throw Exception('Failed to fetch');
}```

Error occurs when debugging rust program with vscode (windows only)

I am trying to debug the code below with vscode, but an error occurs.
Development environment
Microsoft Windows 10 Home 10.0.19042 Build 19042
rustc 1.49.0 (e1884a8e3 2020-12-29)
Vscode 1.54.3
CodeLLDB v1.6.1
// Cargo.toml
//[dependencies]
//datafusion = "3.0.0"
//arrow = "3.0.0"
//tokio = { version = "0.2", features = ["macros", "blocking", "rt-core", "rt-threaded", "sync"] }
use std::time::{Duration, Instant};
use arrow::util::pretty;
use datafusion::error::Result;
use datafusion::prelude::*;
/// This example demonstrates executing a simple query against an Arrow data source (CSV) and
/// fetching results
#[tokio::main]
async fn main() -> Result<()> {
println!("======== Start Program ========");
let start = Instant::now();
// let res_path = r"/root/workspace/project/hello_arrow/res/sample_01.csv";
// http://insideairbnb.com/get-the-data.html
// listing_id,id,date,reviewer_id,reviewer_name,comments
// Boston, Massachusetts, United States
let res_path = r"D:\workspace\vscode\arrow_rust\res\review.01.csv";
// create local execution context
let mut ctx = ExecutionContext::new();
// register csv file with the execution context
ctx.register_csv("datatable_01", res_path, CsvReadOptions::new())?;
// execute the query
let sql = "SELECT count(id) from datatable_01";
let df = ctx.sql(sql)?;
let results = df.collect().await?;
// print the results
pretty::print_batches(&results)?;
let duration = start.elapsed();
println!("Time elapsed in expensive_function() is: {:?}", duration);
println!("======== End Program ========");
Ok(())
}
Error Code
configuration: {
type: 'lldb',
request: 'launch',
name: 'Debug Window',
program: '${workspaceRoot}/target/debug/arrow_rust.exe',
args: [],
cwd: '${workspaceRoot}',
sourceLanguages: [ 'rust' ],
__configurationTarget: 5,
relativePathBase: 'd:\\workspace\\vscode\\arrow_rust'
}
Listening on port 8541
error: arrow_rust.exe :: Class 'arrow::datatypes::DataType' has a member '__0' of type 'alloc::vec::Vec<arrow::datatypes::Field>' which does not have a complete definition.
Debug adapter exit code=3221225620, signal=null.
The program runs normally. Debugging fine on Linux for the same code.
Is there any other way to debug on Windows?
I have the same problem.
Inspired by the link below, I have solved it.
https://github.com/vadimcn/vscode-lldb/issues/410#issuecomment-786791796
The reason is that I have installed NVIDIA Nsight.
As shown below, the msdia140.dll for Nsight has been loaded by codelldb.
Run PowerShell as administrator. Execute the command below to register the component. Then codelldb works.
regsvr32.exe C:\Users\【user name】\.vscode\extensions\vadimcn.vscode-lldb-1.6.8\lldb\bin\msdia140.dll
Update
For newer versions, the DLL has moved to another folder:
regsvr32.exe C:\Users\[user name]\.vscode\extensions\vadimcn.vscode-lldb-1.8.1\adapter\msdia140.dll

Protractor/Typescript : uncaught InvalidElementStateError

I am writing my first protractor test in Typescript..Here is PageObjectModel class
HomePagePOM.ts
export module HomePage{
export class HomePagePom {
helloTextInput = element(by.model("yourName"));
helloTextDisplay = element(by.css("ng-binding"));
launchPage(url: string): void {
browser.get(url);
console.log("success");
browser.waitForAngular();
}
typeHello(text: string): void {
this.helloTextInput.getWebElement().click();
this.helloTextInput.getWebElement().sendKeys(text);
}
getHelloText() : string {
return this.helloTextDisplay.getWebElement().valueOf();
}
}
}
and my spec class HomePageSpec.ts
import id = require("chai");
import hpp = require("./HomePagePOM");
import HomePage = hpp.HomePage;
var expect = id.expect;
var assert = id.assert;
var should = id.should;
describe("Launch the home page", () => {
var homePagePom = new HomePage.HomePagePom();
it("Launch should be successful", () => {
homePagePom.launchPage("https://www.angularjs.org");
assert.equal("test", "test", "test is success");
});
it("Type Hello Text successfully", () => {
homePagePom.typeHello("Arun");
//assert.equal("test", "test", "test is success");
});
it("Type Hello Text successfully", () => {
assert.equal(homePagePom.getHelloText(), "Hello Arun!", " Hello text typed and retrieved successfully");
});
});
when I run the test, I get this error as below
C:\VisualStudio2013\SampleAutomationPOC\SampleAutomationPOC>protractor conf.js
[23:02:59] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[23:02:59] I/launcher - Running 1 instances of WebDriver
[mochawesome] Generating report files...
Launch the home page
success
1) Launch should be successful
2) Type Hello Text successfully
3) Type Hello Text successfully
0 passing (4s)
3 failing
1) Launch the home page Launch should be successful:
Uncaught InvalidElementStateError: invalid element state: Failed to execute 'replace' on 'Location': '' is not a valid URL.
(Session info: chrome=51.0.2704.103)
(Driver info: chromedriver=2.21.371459 (36d3d07f660ff2bc1bf28a75d1cdabed0983e7c4),platform=Windows NT 6.1 SP1 x86_64) (WARNING: The server did not provide any
stacktrace information)
Command duration or timeout: 6 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:06:42'
System info: host: 'ION3076W7LT-3', ip: '10.210.94.178', os.name: 'Windows 7', os.arch: 'x86', os.version: '6.1', java.version: '1.8.0_40'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{applicationCacheEnabled=false, rotatable=false, mobileEmulationEnabled=false, chrome={chromedriverVersion=2.21.371459 (36d3d07f660ff2bc1bf28a75d1
cdabed0983e7c4), userDataDir=C:\Users\ion3076\AppData\Local\Temp\scoped_dir10008_16863}, takesHeapSnapshot=true, databaseEnabled=false, handlesAlerts=true, hasT
ouchScreen=false, version=51.0.2704.103, platform=XP, browserConnectionEnabled=false, nativeEvents=true, acceptSslCerts=true, locationContextEnabled=true, webSt
orageEnabled=true, browserName=chrome, takesScreenshot=true, javascriptEnabled=true, cssSelectorsEnabled=true}]
Session ID: 70409fcf7ae2dfd5a1058292d0c30684
I have 2 problem
1. obviously the error
2. when the script executes the angularjs.org website doesn't load all the components completely. Meaning some of the components are blank and the loading looks completed. (the object i am interacting is not shown on the page). So while the script is running i tried to hit the refresh button quickly twice and then the page loaded completely. Manually launching everything looks fine.. Not sure what is causing the issue.
The object I am interacting is unique as far as i know..
Any clues to help me out? enter code here
thanks in advance.
Never mind ..I figured out the answer. For prep reasons i thought of launching the blank browser, I added a line of code browser.get('') in the conf.js under onPrepare() function section. That is causing the issue as ' ' invalid url. I removed it and now it goes through smooth.. long day...and missed to catch the obvious.
Thanks.