Selenium File Upload Not Working in Azure Pipeline/ VM Machine - selenium

Hi I am Trying Achieve File upload Scenario My Test cases using selenium
Element I am Doing Actions On:-
<input _ngcontent-swn-c63="" type="file" id="undefined" multiple="" accept=".gif, .xlsm, .zip, .xls,.xlsx, .pdf, .ppt, .pptx, .doc, .docx, .jpeg, .jpg, .png, .csv, .txt">
Selenium Script I am Using :-
WebElement UploadElement=(new WebDriverWait(driver, BaseInitializer.defaultwaitTime)).until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//input[#type='file' and #id='undefined']")));
((JavascriptExecutor)driver).executeScript("arguments[0].style.display = 'block';", UploadElement);
UploadElement.sendKeys(newname.getAbsolutePath());
While the above piece of code is working in My Local Machine(Chrome browser). Same script is not working while running the code in Azures Pipeline. The File is not getting reflected in Upload Element. What may be the issue? Or I am missing something?

Related

selenium downloads txt file with > and < instead of > and <

I'm downloading a text file using selenium (Firefox driver) and it has a mix of HTML and xbrl tags. When I look at the website in Chrome, it normally renders greater than signs and less than signs as > and < but when I download the txt file using selenium it has &gt an &lt in place of those elements.
part of actual website rendered in Chrome: txt in chrome
.txt downloaded via selenium:
txt downloaded via selenium using Firefox driver
opts = FirefoxOptions()
opts.add_argument("--headless")
browser = webdriver.Firefox(options=opts)
browser.get(txtURL)
with open(downloadedTxtFileName, "w") as f:
f.write(browser.page_source)
This is because the text file actually contains symbols like &gt and &lt.
When you open this file with browser the browser shows you symbols like < and > instead of the above actual textual symbols.
So, Selenium works correct.

Selenium: Page JS not running, stuck in load

Running a scraper on a site and the js doesn't seem to be working. Stuck on "loading" on the page but the rest of the html is loading fine.
Screen shot of load.
https://i.stack.imgur.com/0WofB.png
from selenium import webdriver
bin_path = ''#path to local bin file for driver
driver = webdriver.Chrome(executable_path=bin_path,desired_capabilities={'javascriptEnabled': True})
driver.get(URL)
Not sure if I need to pull the name of each script and execute it one at a time?

Selenium IDE - Upload file into field

I'm creating a testing suite to automate some parts of data input on my web application. I have a page where I can click on a button to upload a document to the application. It looks something like this:
Once the Add New Attachment button is clicked, it opens the browser's file explorer to select a document to upload. I'm trying to replicate this within Selenium IDE.
Here is what it looks like as of now:
However, this part seems to fail. Does anyone know how to achieve a similar process using Selenium IDE? I'm on Chrome and Firefox.
If you get the
{"code":-32000,"message":"Not allowed"}
on Chrome, follow the steps below:
Window > More Tools > Extensions > Selenium IDE > Details
Then turn on the 'Allow access to file URLs' option.
I was having the same problem and this worked for me.
It is possible to upload the files using selenium IDE. It can be done as mentioned below.
|Command|Target|Value|
|type|target_location_path|location_of_the_file_in_your_system|
Example:
|type|id=ConsignmentCustomerInvoiceFilename|C:\Users\abc\Desktop\img1.jpg|
You can identify the "target_location_path" by manually uploading the file and then finding the xpath of the uploaded file in the web app.
Please refer below screenshot to get a better understanding.
SeleniumIDE_uploadfile
You can add the system path to the IDE test by using the below code.
<tr>
<td>storeEval</td>
<td>Preferences.getString(TestSuite.TEST_SUITE_DIRECTORY_PREF);</td>
<td>testSuiteFolder</td>
</tr>
<tr>
<td>type</td>
<td>id=QuestionUpload_file</td>
<td>${testSuiteFolder}/resources/question_upload.csv</td>
</tr>

download a file using selenium

I have a website that is downloading a file when I press a link.
The source code of the link is:
<a onclick="downloadTheCsv(); return false;" id="ddlkkjs" class="buttonlink" href="javascript:__doPostBack('ctl01$linkebr2','')">Download Comma Separated File</a>
I am using RSelenium but when executing
remDr$executeScript("downloadTheCsv(); return false;")
the file is not downloaded...
However in chrome if I call downloadTheCsv() in the console it works.
Any ideas?

dojo file upload with dojo.io.iframe.send

I have tried to upload file using dojo.xhrPost and couldn't. Then tried dojo.io.iframe.send it works but it results to a normal form submit. Can any one explain to me how the dojo.io.iframe.send works.