I am developing on a program in C# that automates inputting information into a website. This program uses a library (Coypu) that allows this and for the execution of Javascript to manipulate further.
The problem comes in two forms:
document.getElementsByName('name');
because it's not supported in earlier versions of IE. document.forms[formIndex].elements['elementsName'];
(although the tab appears to have focus) only gives me the forms from the main tab. Has anyone ever fixed this problem or found a workaround in Javascript? Also, I'm not sure if jQuery can be used in my scenario as the Javascript is a string passed in to a C# method. However, it may or may not work.
If the website you are testing has access to jQuery you can use Coypu to populate specific fields in their respective forms:
eg
void PopulateInputField(int formName, string fieldName, string fieldValue)
{
browser.ExecuteScript(string.Format("$('form[name='{0}'] > input[name='{1}']).val('{2}')", formName, fieldName, fieldIndex));
}
Note how the C# string passed to Coypu's ExecuteScript contains the jQuery.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.