WebKitBrowser and Iframe - vb.net - vb.net

At first , You need to know that this is my first question and i'm from Poland so very sory for any mistake.
I'm making program in VB.net.
I have site , not my , and there are Iframe. In the iframe is a text input. I need to change value of this input .
I make this in WebBrowser , but i need to make it in WebKitBrowser .
In WebBrowser this looks like:
WebBrowser1.Document.Window.Frames("NameOfFrame").Document.GetElementById("Text_Input").SetAttribute("value", "something")
In WebKitBrowser this don't work.
I'm trying this:
For Each oneelement As WebKit.DOM.Node In WebKitBrowser1.Document.GetElementById("NameOfFrame").ChildNodes
MsgBox(oneelement.NodeValue.ToString)
Next
One problem ..
I'm getting the msg:
"You need iframe support!"

Related

Unable to access the element in the frame

I am still dipping my toes in selenium , I am SAP guy working on Selenium automation POC. my requirement is to click on the drop down and select a value from the droplist.
I have extensively looked at the previous posts but could not find any answers. I have tried all the suggestions from the post but nothing seems to be working for me.
Please can you help me how to access this drop down value.
HTML code is attached in the pic along with the element that I am trying to access
My selenium code :
driver.switchTo().frame(driver.findElement(By.name("SMFrame")));
System.out.println("TExt" + driver.findElement(By.xpath("//div[#class='file-type']")).getText());
Error:
error -- > no such element: Unable to locate element: {"method":"xpath","selector":"//div[#class='file-type']"}
Image
Assuming you are correctly getting into the iframe
Right now you are selecting a div above the actual dropdown element (the select-dropdown tag). You may want to try changing your xpath to search for the tag like so:
//div[#class='file-dropdown']/select-dropdown
Also you should be creating a dropdown object like this. Then calling a method on it to select the dropdown option you are looking for:
Select dropdown = new Select(driver.findElement(By.xpath("//div[#class='file-dropdown']/select-dropdown");
System.out.println(dropdown.selectByVisibleText("text that you are looking for in the options"));
This is a good explanation of how to do it: https://www.javatpoint.com/selenium-webdriver-handling-drop-downs

applescript getInputByClass2 with Safari 10.1

My Applescripts I used to run everyday to get text from Safari isn't working since my last system update
It used to work only in Safari, and not in Safari Preview, I guess the system for Safari Preview was bring to safari now/
tell application "Safari"
set DinfoGrab to do JavaScript "
document.getElementsByClassName(' field type-string field-Dinfo ')[0].innerHTML;" in tab 3 of window 1
end tell
with this error :
Safari got an error: Can’t make " document.getElementsByClassName('
field type-string field-Dinfo ')[0].innerHTML;" into type text.
how can I fix that? thanks.
UPDATE :
Here is something working perfectly with Chrome :
tell application "Google Chrome"
tell tab 3 of window 1 to set r to execute javascript "document.getElementsByClassName('field type-string field-Dinfo')[0].innerHTML;"
end tell
Without seeing the complete code, I can't say for sure what's going on. But judging by the name of your function -- getInputByClass2 -- I assume you're trying to get the value of HTML <input> fields. If this is true, you should be using outPut.push(arr[i].value) instead of outPut.push(arr[i].innerHTML)
As for the second bit of code, your JavaScript doesn't have any error handling in case the value of document.getElementsByClassName(' field type-string field-Dinfo ')[0] is null.
var els = document.getElementsByClassName(' field type-string field-Dinfo ');
//set to value of [0].innerHTML if [0] exists, else empty string
var html = els.length ? els[0].innerHTML : "";
//return value to AppleScript
html;
update (response to updated question)
Running the following script in Script Editor against this StackOverflow page will return the correct value (assuming you have the correct window/tab numbers set). If the search field at the top of this StackOverflow page is empty, you will get an empty string. If you enter a term (but don't submit) then run the AppleScript, you will get the value of the field.
tell application "Safari"
set DinfoGrab to do JavaScript "
document.getElementsByClassName('js-search-field')[0].value;" in tab 1 of window 1
end tell
The only changes from your script are the window/tab numbers, the classname (changed to match the StackOverflow page), and I used value instead of innerHTML.
I have tested in the most current version of Safari (10.0.3); if this doesn't work in your version of Safari, ensure you're pointing to the correct class name. If this script DOES work for you, then the issue is probably due to something on the page you're trying to search, perhaps related to the type of <input> field you're fetching or an incorrect classname. Maybe the update to Safari is causing the page to render differently, which indirectly affects your code.

Autohotkey: Save variable into forum field

I am trying to write an autohotkey script to fill an online forum using COM. My problem is that the username is incremented by numbers, so ideally I want to loop the script to fill the form 5 or 6 times.
Here is the autohotkey part I am struggling with:
number := 28
username = user%number%
wb.document.all.getElementById(username).value := "username" ;HERE IS THE PROBLEM
number++
I have tried %username%, username without quotes, and with single quotes, and nothing seem to be working.
any ideas?
Thanks for your help.
First thing that popped out to me was all in you, I see Joe DF asked if you had tried without?
Second thing is you shouldn't have ""'s around your Variable.
If you are doing multiple assignments you can enclose them in ()'s like so:
:= (UserName "`n" Address "`n" PhoneNumber "`n" SocialSecurity)
If you are having problem's with a document not fully being loaded you can implement a custom loading routine like so:
wb.Navigate("Yourwebsite")
GoSub loading
.
.
.
loading:
ComObjError(false) ;turn off com errors
While value = "" {
value := wb.document.getElementsByClassname("somethingHere") [0].innerText
Continue
}
ComObjError(true)
Return
Without seeing more of your code and the website you are trying to work with, it will be difficult to help you further.
It worked... turns out it was the sleep time for the form to load. form was slower than Sleep 100 for some reason. Now, the form loads, but it is only taking 1 field. so password and email are not being filled.

web2py SQLFORM accepting too fast

I have a web2py SQLFORM that gets generated and returned by an AJAX call and the form is put in a DIV I defined.. I want that SQLFORM to be an update form, not an insert form. The problem is the form immediately runs it's accept function once it is written to that DIV. This doesn't happen if the form is for inserting, only updating. That initial accept fails and hitting the submit button does not allow for a second accept.
I don't know why the accept fails or why it happens immediately.
heres the JavaScript function that makes the AJAX call
function displayForm(currID){
//Remove everything from the DIV we want to use
$('#window').empty();
//Call the ajax to bring down the form to update the series
ajax('{{=URL('newForm')}}/'+currID,
[], 'window');
}
And here is the newForm controller
def newSerForm():
record = db.myTable(request.args[0])
form = SQLFORM(db.myTable, record, fields=['series_name','image_thumbnail'])
if form.accepts(request.vars,session):
print 'Series update successful!'
else:
print 'Series update Failed...'
return form
displayForm is fired by clicking a button and once you do the form accepts and fails and the submit button doesn't work again. Is there a way to make an SQLFORM do this? The weird thing is if I change this to make inserts into myTable, it works fine. It behaves exactly as it should. But doing it this way doesn't work.
Ok now this is where it gets weird.
I tried to achieve the same functionality here with a totally different approach, an iFrame. I made new functions in my controllers that create the form based on request.args[0]. looks like this
def editEntry():
print request.args[0]
record = db.myTable(request.args[0])
form = SQLFORM(db.CC_user_submission, record, fields=['series_name', 'image_thumbnail']).process()
return dict(form=form)
And then a corresponding HTML page that just displays form. What could be simpler right? I go to that page based on a link that gives the correct argument. Take me to a page with a form for updating. Updating works perfect. Great, now lets put it in an iFrame instead of linking to it. I put it in an iFrame on the original page. Open up the iFrame. Doesn't work. I have no idea what is going is there any part of an explanation to this?
By using the iFrame method I actually got this one to work. Since it required an iFrame to be appended with jQuery which needs quotes and the iFrame URL which also needs quotes, the notation got pretty confusing but it's doable. Looked like this:
var myURL = "{{=URL('editEntry')}}/"+idArg.toString();
$('#window').append("<iframe src = " + myURL + " width='450' height='400'> </iframe>");
It's not pretty but it works.

How can I store a dynamic text value in selenium ide and use it later in different window

I am new in selenium and trying to learning. I am creating a script and I got stuck here, I want to store a dynamic value from text message on web page ex. " Event Name:Test" this Event Name is dynamic and I want to store this and want to get in other window. In 2nd window i want to use this value(Test) to verify in the page
I tried storeValue, StoreText and storeAttribute command and getting error message for xpath or "element not found".
Please help me and advice me , what should I do?
Can You please suggest me the Xpath for storing and retrieving the event name. Please help me...
Thanks in advance,
Niru
If you are using the same test-case to navigate from page 1 to page 2 you can use the storeText function in the IDE to store the value of your event name. And then you can use the same variable in the page 2 for verification.
For example, in page 1 to store the value of event you use:
storeText(locator1, temp)
And then on page 2 you use assert:
assertText(locator2, ${temp})